임, 문제는사용자 정의 목록보기,보기 문제
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는 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' 클래스 (행이 아니고 어댑터이고 많은 행을 표시하므로 이름을 바꾸는 것이 좋습니다)를 볼 필요가 있습니다. 그럼 우리는 또한 하나의 행의 XML 레이아웃을 볼 필요가 –
귀하의 질문에 [편집]과 함께 [mcve]를 보여주십시오 –