私が正しくあなたの問題を解釈している天気をに応じて、これはアダプタで行うことが可能でなければなりません異なるリスト。リサイクルしやすい化合物のビューを構築するために選択したのViewGroupのサブクラス
:しかし必要everyithingない
public class DoubleText extends LinearLayout {
TextView t1, t2;
public DoubleText(Context c) {
super(c);
t1 = new TextView(c);
t2 = new TextView(c);
this.addView(t1, 0);
this.addView(t2, 1);
}
public void setText(String s1, String s2) {
t1.setText(s1);
t2.setText(s2);
}
}
サブクラスBaseAdapterが、示され、そこに、より多くのです 把握しやすくする必要があります、大きな違いは、アダプタを使用してに関する他の例に比べて あるこのとして:
public class DoubleAdaptor extends BaseAdaptor {
List<String> lista, listb; // <- these are your paralell arrays, they and the
Context c; // context need to be initialized by some method
@Override
public View getView(int position, View convertView, ViewGroup parent) {
DoubleText recycled = (DoubleText) convertView;
if (recycled == null) {
recycled = new Double(context);
recycled.setText(lista.get(position), listb.get(position));
return recycled;
}
}
また、あなたが肝炎にする必要はありませんすべての行で同じビュータイプ、つまりオーバーライド 異なるビューの数の上限をアンドロイドに与えるためのgetViewTypeCount() 使用するタイプと、その特定のリサイクルするビューのタイプ をアンドロイドに伝えるgetItemViewType(int position)行。
編集:アダプタ(インターフェイス)とBaseAdapter(抽象クラス)とListAdapter(インターフェイス)のAndroid開発者ドキュメントをチェックすることをお勧めします。また、ListViewにはsetAdapter()興味を持っている。