nayden
nayden

Reputation: 875

ANDROID: on Notification received, I want to refresh the listView with the new data

Ths activity it's call from TabActivity.

And I want: if I receive new notification , I want to refresh the list of the current Activity.

public class TestListActivity extends ListActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    ListView lv = null;
    super.onCreate(savedInstanceState);

    setListAdapter(new ArrayAdapter<String>(this, R.layout.test_list, ListUtil.asStringList(TestServiceUtil.getTests())));

    lv = getListView();
    lv.setSelector(R.drawable.listindicator);
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(TestListActivity.this, TestViewActivity.class);

            // Next create the bundle and initialize it
            Bundle bundle = new Bundle();

            // Add the parameters to bundle as
            bundle.putLong("testId", TestServiceUtil.getTests().get(position).getTestId());

            // Add this bundle to the intent
            intent.putExtras(bundle);

            // Start next activity
            TestListActivity.this.startActivity(intent);
        }
    });
}
}

I need just example, how i can make the refresh of the list.

Upvotes: 2

Views: 915

Answers (1)

coder
coder

Reputation: 10520

I recommend using notifyDataSetChanged() on the ArrayAdapter.

Upvotes: 1

Related Questions