イムとイム、問題は、それがカスタムリストビュー、アンドロイドスタジオで全く新しいビューの問題
Name
Name
------
Surname
Surname
-----
として、間違ったリストを作成...と
何を繰り返すことです私がやりたいです:
Name
Surname
-------
私のコードは次のとおりです。
protected void onResume() {
DBHelper db = new DBHelper(this);
ArrayList<String> names = new ArrayList<String>();
for (int i = 0; i < db.getAllContacts().size(); i++) {
names.add(db.getAllContacts().get(i).getName());
names.add(db.getAllContacts().get(i).getEmail());
}
ArrayAdapter adapter = new custom_row(this, names);
listView_allContacts.setAdapter(adapter);
super.onResume();
}
ここで何が間違っていますか?前もって感謝します!
マイcustom_rowコード:
パブリッククラスcustom_rowは、あなたが名前と電子メールのいずれかの二つの異なるArrayListのいずれかが必要ArrayAdapter {
public custom_row(Context context, ArrayList<String> names) {
super(context, R.layout.custom_cell, names);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater peoInf = LayoutInflater.from(getContext());
View customView = peoInf.inflate(R.layout.custom_cell, parent , false);
String singlePeople = getItem(position);
TextView name_text = (TextView) customView.findViewById(R.id.name_text);
TextView email_text = (TextView) customView.findViewById(R.id.email_text);
name_text.setText(singlePeople);
email_text.setText(singlePeople);
return customView;
}
}
を試してみてください – Vyacheslav
あなたを助けるための十分な詳細がここにありません。 'custom_row'クラス(行ではなく、アダプタであり、多くの行を表示するので、名前を変更することをお勧めします)を参照する必要があります。次に、1行のXMLレイアウトを参照する必要があります –
あなたの質問に[編集]で[mcve]を表示してください –