java.lang.IllegalStateException: ViewPager has not been bound (Using JakeWharton ViewPager Indicator)

余生长醉 提交于 2020-01-23 06:51:39

问题


I have two view pagers in a screen.One ViewPager uses JakeWharton' circleindicator and second one uses TabPage Indicator. I need to download the data from backend using Async call.Once the data is download i should be displaying the data in the viewpagers. Here is the Code snippet of my activity.

   ViewPager pager1;
ViewPager pager2;

public onCreate(){
     //I Set Up ContentView
     //Locate ViewPagers & Indicators
     //pager1 = ...
     //pager2= ...
     //Locate Indicators
     CallAsyncTask().execute();


}
private class CallAsyncTask extends AsynTask{
          doinbackground(){
          //Download Data
          }
          onPostExecute(){
            displayData();

          }

}
private displayData(){
   // Set Up Adapters & Indicators for ViewPagers
}

when i execute this code, i get ViewPager Not Bound Exception. Is there a solution for it. I think a workaround is to setUpContentView inside onPostExecute() method of AsyncTask.But i also need to display progressBars till the data is downloaded. How can i achieve all of this.


回答1:


I just placed visibility: gone on the TabPageIndicator and when I get the data to display I change the visibility to visible




回答2:


In my case what i found is that i am not setting the "ViewPager" to "TabPageIndicator". After setting

indicator.setViewPager(pager);

my issue is gone.



来源:https://stackoverflow.com/questions/22859492/java-lang-illegalstateexception-viewpager-has-not-been-bound-using-jakewharton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!