When i set the adapters to viewpager after the onPostexecute method of Async Task has finished, i get this Exception and app Force closes. "ViewPager has not been bound"
I am using jakeWhartons Viewpager indicator for TabPage Indicators.
Is there a fix to it?
code snippet.
public class MyDetailedActivity extends FragmentActivity {
ViewPager pager;
PageIndicator mIndicator;
ProgressBar progressBar1;
ProgressBar progressBar2;
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.ac_image_pager);
progressBar1 = (ProgressBar)findViewById(R.id.progressBarPager1);
progressBar2 = (ProgressBar)findViewById(R.id.progressBarPager2);
progressBar1.setVisibility(View.VISIBLE);
progressBar2.setVisibility(View.VISIBLE);
//Declare Pagers & Indicators
//Pager-Top
pager = (ViewPager) findViewById(R.id.pager);
pager.setClipToPadding(false);
pager.setPageMargin(12);
//Indicator of Pager-Top
mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
new PastEventFullDetailDownloader(past_event_id).execute(null,null,null);
}
private class PastEventFullDetailDownloader extends AsyncTask<String,String, String>
{
protected String doInBackground(String... params) {
//Download data
}
protected void onPostExecute(String result) {
displayEvent(result);
}
}
void displayEvent(PastEventInfo event)
{
//hide the progressbars
progressBar1.setVisibility(View.GONE);
progressBar2.setVisibility(View.GONE);
//Set Up Adapter for First Pager ..Pass ImageUrsl Just Downloaded
pager.setAdapter(new ImagePagerAdapter(event.getEventImageUrsl()));
pager.setCurrentItem(pagerPosition);
mIndicator.setViewPager(pager);
}
}