0
我曾與editTextView和TextView的一個haderListView: 當我點擊添加圖標,我添加了一個列表至極我可以填補空editTextView, 的問題來了,當我加入項目2清單:當我開始完成第一個清單,我發現第二個清單採用了相同的數據, 我如何分配每個清單的項目。添加EDITTEXT在HeaderListView安卓
這在Seconde系列列表中我發現,從第一個
tooks數據我的問題如何是否有分離形式?
這是我的適配器:
public class SectionAuthorAdapter extends com.applidium.headerlistview.SectionAdapter {
private MainActivity mainActivity;
private Realm realm;
private Author author = null;
private Authors_groups authors_groups = null;
private RealmList<Author> authors = new RealmList<>();
int num= 0;
private List<Authors_groups> authors_groupses;
public SectionAuthorAdapter(MainActivity mainActivity, List<Authors_groups> authors_groupses) {
this.mainActivity = mainActivity;
realm = Realm.getInstance(mainActivity);
this.authors_groupses = authors_groupses;
}
@Override
public int numberOfSections() {
return authors_groupses.size();
}
@Override
public int numberOfRows(int section)
{
if(section == -1)
section = 0;
return authors_groupses.get(section).getAuthors().size();
}
@Override
public View getRowView(int section, int row, View convertView, ViewGroup parent) {
final int id ;
//ViewHolder holder = null;
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
LayoutInflater inflater = mainActivity.getLayoutInflater();
convertView = inflater.inflate(R.layout.listview_item_agent, null);
holder.textView1 = (TextView) convertView.findViewById(R.id.textView1);
holder.editText1 = (EditText) convertView.findViewById(R.id.editText1);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
realm.beginTransaction();
id = authors_groupses.get(section).getAuthors().get(row).getId();
authors_groups = new Authors_groups();
author = authors_groupses.get(section).getAuthors().get(row);
if (author != null) {
holder.textView1.setText(author.getField().getLabel() + " : ");
if (author.getData() != null && !author.getData().isEmpty())
{
holder.editText1.setText(author.getData());
}
holder.editText1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
holder.editText1.getId();
}
});
authors.add(author);
authors_groups.setAuthors(authors);
}
realm.commitTransaction();
return convertView;
}
@Override
public Object getRowItem(int section, int row) {
return null;
}
@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = (TextView) mainActivity.getLayoutInflater().inflate(mainActivity.getResources().getLayout(android.R.layout.simple_list_item_1), null);
}
section = section+1;
((TextView) convertView).setText("Témoin : " +section);
convertView.setBackgroundColor(mainActivity.getResources().getColor(R.color.android_green));
return convertView;
}
@Override
public boolean hasSectionHeaderView(int section) {
return true;
}
@Override
public void onRowItemClick(AdapterView<?> parent, View view, int section, int row, long id) {
super.onRowItemClick(parent, view, section, row, id);
}
class ViewHolder {
TextView textView1;
EditText editText1;
}
}
謝謝,但它不工作。 – Euphor08
但這種方法從我工作:( – Rifan
你可以給我一部分的代碼? – Euphor08