Добавить EditText в HeaderListView AndroidAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Добавить EditText в HeaderListView Android

Сообщение Anonymous »

У меня был headerListView с editTextView и TextView:
Когда я нажимаю значок «Добавить», я добавляю список, которым могу заполнить пустой EditTextView.
Проблема возникает, когда я добавляю 2 списка элементов: когда я начал заполнять первый список, я обнаружил, что второй взял те же данные.
Как я могу разделить элементы каждого списка.
это первый список, я положил тест в функции
Изображение

во втором списке я нашел это, он берет данные из первого
Изображение

Мой вопрос, как сделать, чтобы иметь отдельная форма?
это мой адаптер:
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 authors = new RealmList();
int num= 0;
private List authors_groupses;

public SectionAuthorAdapter(MainActivity mainActivity, List 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;

}
}


Подробнее здесь: https://stackoverflow.com/questions/390 ... ew-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»