MainActivity
があるListView
と想像してみてくださいArrayAdapter
。に属するビューではMainActivity
、データを直接更新します。たとえば、私のPageAdapter
クラスでは:
@Override
public void finishUpdate(View arg0) {
ViewPager vp = (ViewPager) arg0;
if (vp.getCurrentItem() != this.current_item){
this.current_item = vp.getCurrentItem();
ContentStatus status;
switch(vp.getCurrentItem()){
case(0):
status = ContentStatus.NOTINTERESTING;
break;
case(2):
status = ContentStatus.INTERESTING;
break;
default:
status = ContentStatus.ACTIVE;
}
MainActivity.content.setItemStatus(content.identifier, status);
final Activity act = (Activity) this.context;
ArrayAdapter adapter = (ArrayAdapter) ((ListView) act.findViewById(R.id.view_sequence)).getAdapter();
adapter.notifyDataSetChanged();
}
}
MainActivity
ユーザーが他のアクティビティから一部のデータを変更してから閉じてMainActivityに戻る場合は、のビューを再描画する必要があるため、から開いて同じデータを使用する別のアクティビティでこのコードを再現する必要がありMainActivity
ます。バリアントとして、Activity
のonResume()
メソッドを使用して、データにバインドされているすべてのビューを更新する必要がありますか?