これは私がこれまでに持っているものです:
カスタム オブジェクト:
class ItemObject {
List<String> name;
List<String> total;
List<String> rating;
public ItemObject(List<ItemObject> io) {
this.total = total;
this.name = name;
this.rating = rating;
}
}
アダプターへの呼び出し:
List<String> names, ratings, totals;
ItemObject[] io= new ItemObject[3];
io[0] = new ItemObject(names);
io[1] = new ItemObject(rating);
io[2] = new ItemObject(totals);
adapter = new ItemAdapter(Items.this, io);
setListAdapter(adapter);
上記が問題ないと仮定すると、私の質問は、コンストラクターである ItemAdapter をどのようにセットアップし、オブジェクトから 3 つのリストをアンラップするかということです。そして、getView で、次のものを割り当てます。
一致する各位置は次のとおりです。
TextView t1 = (TextView) rowView.findViewById(R.id.itemName);
TextView t2 = (TextView) rowView.findViewById(R.id.itemTotal);
RatingBar r1 = (RatingBar) rowView.findViewById(R.id.ratingBarSmall);
たとえば、配列「names」の位置 0 を t1 にします。配列「totals」の 0 を t1 に配置します。配列「ratings」の 0 を r1 に配置します。
編集: 誰かにアダプター全体を書いてほしくありません。データを使用できるように、カスタム オブジェクトからリストをアンラップする方法を知る必要があるだけです。(別の質問で取り上げられていない、または尋ねられていないもの)