私は実際にデータベースから項目を入力することによってListViewを作成しています。
リストビューの終わりに達すると、私はいくつかの項目を追加します。今、私は、データベースから返された値に基づいて、ListViewの仕切りをします。データベースの2つの連続した値が同じであれば、それらを細い線で区切り、太い線ではないにします。Listview custom ListDivider
私は条件に基づいて新しいレイアウトを膨らませています。この
if (convertView == null) {
holder = new ViewHolder();
if (eventSource.get(position).equalsIgnoreCase("asdsadas")
&& eventSource.get(position + 1).equalsIgnoreCase(
"fdgdfgfd")
|| eventSource.get(position).equalsIgnoreCase(
"dfgdfgdfg")
&& eventSource.get(position + 1).equalsIgnoreCase(
"jgghjhhgg")) {
convertView = mInflater.inflate(R.layout.list_adapter, null);
} else {
convertView = mInflater.inflate(R.layout.list_adapterthinline,
null);
}
のようにアダプタを介してそれらを設定してみました。これは初めてのことですが、下にスクロールしてから、ビューが変わります。すべてが混ざり合ってしまいます。
私はアクティビティでディバイダの高さを設定しようとしました。このように、私はonCreateとonScrollリスナで 'setdivider'メソッドを呼び出します。
public void setdivider() {
// TODO Auto-generated method stub
for (int i = 0; i < listSource.size() - 1; i++) {
if (!listSource.get(i).equalsIgnoreCase(
listSource.get(i + 1))) {
Log.v("inside not equals", "become smalllllllllllllllll");
list.setDivider(red);
list.setDividerHeight(5);
} else if (listSource.get(i).equalsIgnoreCase(
listSource.get(i + 1))) {
Log.v("inside equals", "become bigggggggggggg");
list.setDivider(blue);
list.setDividerHeight(10);
}
}
}
ただし、両方のログコメントはLogCatに表示されますが、リストには1つのディバイダしか設定されていません。
どこが間違っているのか教えてください。
ありがとうございました。 – user669444
その仕組みが不思議な人には、このリンクを参照してください。http://logc.at/2011/10/10/handling-listviews-with-multiple-row-types/ – user669444