2011-10-21 14 views
2

TabActivityから呼び出されるアクティビティです。ANDROID:通知を受信したとき、新しいデータでlistViewを更新したいです。

私は新しい通知を受け取った場合、現在のアクティビティのリストを更新したいと思います。

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); 
     } 
    }); 
} 
} 

私はどのようにリストの更新を行うことができますか?

+0

どのような通知ですか? – fredley

答えて

1

ArrayAdapterでnotifyDataSetChanged()を使用することをお勧めします。

+0

はい、私はすでにそれを使用していただきありがとうございます、それは動作します;) – nayden

関連する問題