I want to display editbox data in verbose only after checkbox checked which is created in Listview with ArrayAdapter type Datalist
//Adapter Code
checkbox=view.findViewById(R.id.checkbox); final int i=position;
if (DataList.getCheckbox()){
checkbox.setChecked(true);
}else{
checkbox.setChecked(false);
}
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
list.get(i).setEdittext(s.toString());
}
});
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (checkbox.isChecked()==true){
checkbox.setChecked(false);
}else if(checkbox.isChecked()==false){
checkbox.setChecked(true);
}
}
});
// Mainactivity Code
final ArrayList<DataList> list = new ArrayList<>();
final DataList item = new DataList();
item.setEdittext("");
item.setCheckbox(true);
DataList item1=new DataList();
item1.setEdittext("");
item1.setCheckbox(false);
list.add(item);
list.add(item1);
list.add(item);
list.add(item1);
list.add(item);
list.add(item1);
list.add(item);
list.add(item1);
list.add(item);
list.add(item);
final GetAdapter adapter = new GetAdapter(MainActivity.this,list);
listView.setAdapter(adapter);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DataList.getCheckbox();
if (checkbox.equals(true)) {
for (int i = 0; i < list.size(); i++) {
String saveddata = list.get(i).getEdittext();
Log.d("D", "Data:" + saveddata);
}
}
}
});
I want to get data from editbox at run time by click on submit button only checkbox checked
Aucun commentaire:
Enregistrer un commentaire