I have recyclerview with edit text. Each row has a edit text. I am entering values in the edit text manually and after i enter values, I want to get those values in each and eve
You don't need to use so many lists, just create a class that will contain all the data of single item, there is no need for buttons, use just text change listener instead.
sample code
public class RetItem
{
public String _itemName;
public String _itemQty;
public String _itemPcode;
public String _itemPlant;
}
public class SelectItemAdapter extends RecyclerView.Adapter {
private List _retData;
public SelectItemAdapter(Context context, String[] mDataset) {
layoutInflater = LayoutInflater.from(context);
_retData = new ArrayList(mDataset.length);
this.mDataset = mDataset;
}
@Override
public void onBindViewHolder(SelectItemAdapter.ItemHolder holder, final int position) {
holder.setItemName(itemsName.get(position));
holder.setItemName.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
_retData.get(position)._itemName = s.toString();
}
});
holder.setItemQty(itemsQty.get(position));
holder.setItemQty.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
_retData.get(position)._itemQty = s.toString();
}
});
holder.setItemPCode(itemsPCode.get(position));
holder.setItemPCode.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
_retData.get(position)._itemPcode = s.toString();
}
});
holder.setItemPlant(itemPlant.get(position));
holder.setItemPlant.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
_retData.get(position)._itemPlant = s.toString();
}
});
}
public List retrieveData()
{
return _retData;
}
}