Използвам списък за преглед в дейността ми с списъка за прегледи с този списък:
setListAdapter(new ArrayAdapter<MyItem>(this,R.layout.catalog, R.id.label, items));
всеки елемент има свойство ... как мога да го отпечатам?
Отговори:
2 за отговор № 1Добавете a TextView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/item_label" />
</LinearLayout>
Задайте стойността на този текстов преглед в метода на преодоляване на персонализирания адаптер getView
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.catalog, null);
}
MyItem m = items.get(position);
TextView itemLabel = (TextView) v.findViewById(R.id.item_label);
itemLabel.setText(m.getItemLabel());
return v;
}