我有ViewPager
一页和Tab's
。在AsyncTask
我加载数据并更新ViewPager
,但没有任何改变。在我检查的 LogCat 中,我需要数据。
主类.java
mViewPager = (ViewPager) findViewById(R.id.cinema_view_pager);
mTabPager = new TabPager("Загрузка");
mViewPager.setAdapter(mTabPager);
LoadCinema cinema = new LoadCinema(this,0);
cinema.execute();
TabPager(Adapter).class
public class TabPager extends PagerAdapter{
private String message = "";
public TabPager(String msg){
message = msg;
}
@Override
public int getCount() {
return 1;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}
public void update(String msg){
message = msg;
notifyDataSetChanged();
}
@Override
public View instantiateItem(View container, int position){
View v = getLayoutInflater().inflate(R.layout.cinema_layout, null);
TextView text = (TextView) v.findViewById(R.id.textView1);
text.setText(message+"Message" +"");
((ViewPager) container).addView(v);
return v;
}
public void destroyItem(View container, int position, Object object) {
((ViewPager) container).removeView((View) object);
}
}
LoadCinema.class
public void onPostExecute(List<CinemaCategory> result){
super.onPostExecute(result);
CinemaCategory cat = result.get(page);
cinema.mTabPager.update(cat.getDescription());
}
我尝试了三页,当我 swype 到最后一页时,我有数据,然后 swype 到第一页视图寻呼机更新。