【发布时间】:2014-10-02 03:26:39
【问题描述】:
我的应用发生了奇怪的崩溃。
在我的布局上,我有一个独立于我的 viewPager 的 TextView,它具有 android:layout_below 属性,因此,TextView 的父级是一个具有 ID rl 的 RelativeLayout,而 ViewPager 也是:
现在,当我更改 ViewPager 的适配器时,我同时更改了 TextView 的文本,我得到以下IllegalStateException:
ChiamataPOST chiamata = new ChiamataPOST(WSEntity); // My AsyncTask
chiamata.execute(WS); // I execute it
cittaSceltaTV.setText("whatever text"); // and I change my textView, I've tried to do it before and after the AsyncTask.
java.lang.IllegalStateException:应用程序的 PagerAdapter 更改了适配器的内容,而没有调用 PagerAdapter#notifyDataSetChanged!预期的适配器项目数:4,找到:0
但如果我评论 TextView 的 setText() 的功能,它会完美运行。
这很奇怪吗?我错了吗?
提前致谢。
【问题讨论】:
标签: android android-viewpager textview illegalstateexception android-pageradapter