Into my project I am using viewpager with three tabs named History,Main,Map.Main activity contain Timer,stopwatch,etc
@Override
public Object instantiateItem(View arg0, int arg1) {
Log.d("instantiateItem", ""+arg0+" "+arg1);
try {
if(mListViews.get(arg1).getParent()==null)
((ViewPager) arg0).addView(mListViews.get(arg1), 0);
else{
// I am new to android, it is strange that the view to be added is already bound to a parent
// Through trials and error I solve this problem with the following codes
// Add that the element of mlistviews is listview in pagerview;
((ViewGroup)mListViews.get(arg1).getParent()).removeView(mListViews.get(arg1));
((ViewPager) arg0).addView(mListViews.get(arg1), 0);
}
} catch (Exception e) {
Log.d("parent=", ""+mListViews.get(arg1).getParent());
e.printStackTrace();
}
return mListViews.get(arg1);
}