I have created view from inflating separate layout. I used for loop to create view more than 5 view like an ListView. Here I want call balance check. Inside view, I will click balance button and once receive response from server, I want to update particular TextView in an existing created view. Any help? I am expecting same for phonepe app balance checking page. while scrolling also, it should not hide the updated balance. My Ref stack link: Updating a textview in different layout xml from the main activity
Create a custom View by inflating a layout? My Sample Code:
for (int i=0; i<AccNoList.size; i++) {
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.my_table_row, myTable, true);
inflater.setId(i);
ImageButton balancebtn = (ImageButton) v.findViewById(R.id.balancebtn);
TextView textview_accnumber = (TextView) v.findViewById(R.id.textview_accnumber);
textview_accnumber.setText("Text for this row");
balancebtn.setId(i); // So that when it is clicked we know which one has been clicked!
balancebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// once received value from server, i want to update the same row textview balance.
checkBalance(i);
}
});
textview_accnumber.setId(i);
tr.setId(i);
textview_accnumber.setText(AccNoList.get(i));
linearlayout.addView(inflater);
}
position
here? – Gauderylinearlayout.addView(inflater);
-> How did you add inflater ? did this work? . – Gaudery