Reputation: 7141
I've a Listview with add button when i click add new row of buttons created dynamically. When i scroll listview these new buttons are visible. How can i click add buttons then the buttons are immediately visible. Why it is happened. There is any way to handle this issue.
I've try invalidateViews()
invalidate()
it doesn't work. Please help me to solve this .
My sample code here
a
dd_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
button = new Button(getApplicationContext());
linear.addView(button1, lparams);
listview.invalidateViews();
}
}
Upvotes: 2
Views: 110
Reputation: 7141
I've solve my issue like this. Call this method
//Here running boolean value
//lv listview
private void scrollMyListViewToBottom() {
lv.post(new Runnable() {
public void run() {
if (!running) {
// Select the last row so it will scroll into view...
iv.setSelection(daily_dairy_2.getCount() - 1);
lv.invalidateViews();
running = true;
}
}
});
}
Upvotes: 0
Reputation: 5068
you can use listview.notifyDatasetChanged() method to refresh your list.
Upvotes: 0
Reputation: 516
To refresh a Listview, create a ListAdapter and populate it with your items (buttons). Every time you put in it a new set of items, your list gets updated.
Check this reference on ListViews: http://developer.android.com/guide/topics/ui/layout/listview.html
Upvotes: 1