各行がTextViewであるListViewがあり、テキストの行を表示します。不要な空の行が表示されることがあるという問題が発生しています。リストがその特定の領域を超えてスクロールすると、空の行は消えます。
デバッガーでアプリを一時停止した後、次のコードを使用して、リスト行に正しい情報が含まれていることを確認しました。出力には、空またはnullなどは表示されません。
for (int i = 0; i<list.getChildCount(); i++) {
System.out.print((TextView) list.getChildAt(i)).getText());
}
これは私が期待した情報を示しています。
また、アダプタを裏付けるデータで、空のエントリや新しい行などがないかどうかを確認しました。
アダプタ内のgetView()メソッドは次のとおりです。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView t;
if (convertView == null) {
convertView = mInflator.inflate(R.layout.single_message_row, null);
t = (TextView) convertView;
t.setMovementMethod(LinkMovementMethod.getInstance());
t.setTextSize(mMsgSize);
}
else {
t = (TextView) convertView;
}
CharSequence text = get(position);
t.setText(text);
return t;
}
以下は、問題を示す画像(赤い領域)です。