I'm calling
listView.setFooterView(v)
but no changes are visible. Now I have to add that the listView is inside the view (not the frament) that is added to the ViewPager.
Thus, the view containing the listView is inside the view pager. If I switch between views, I see a change, but not otherwise. So far I have tried to invalidate most of everything, including the entire ViewPager, but still it does not appear.
Inside the activity layout I have:
<android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/white" android:layout_weight="1" />
Then I have three pages, each of which looks like this:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listListDisplayer1" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@+id/listMyList1" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="#00000000" android:fastScrollEnabled="true" /> <include layout="@layout/advertisement" /> </FrameLayout>
So, I have such views as shown above, and create them immediately in onCreate () of the main action.
MyPageAdapter extends ViewPagerAdapter{ int getCount() { return 3; } public Object instantiateItem(View collection, int position) { View view=null; switch (position) { case 0: view = getMyView1(); break; case 1: view = getMyView2(); break; case 2: view = getMyView2(); break; } if ((view != null) && ((ViewPager) collection).findViewById(view.getId()) == null) { ((ViewPager) collection).addView(view, 0); } return view; } private View getMyView1() { return mMyView1; } private View getMyView2() { return mMyView2; } private View getMyView3() { return mMyView3; } @Override public void destroyItem(View view, int arg1, Object arg2) { ((ViewPager) view).removeView((View) arg2); } @Override public void finishUpdate(View view) { } @Override public boolean isViewFromObject(View view, Object arg1) { return view == ((View) arg1); } @Override public void restoreState(Parcelable parcel, ClassLoader classLoader) { } @Override public Parcelable saveState() { return null; } @Override public void startUpdate(View view) { } }
I will update a few more lines ....
private class PageChangeListener implements OnPageChangeListener { @Override public void onPageScrollStateChanged(int scrollState) { // TODO Auto-generated method stub } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { // TODO Auto-generated method stub } @Override public void onPageSelected(int pageNum) { Logout.debug("pageSelected :"+pageNum); if (pageNum == 0) { prepareMyView1(); } else if (pageNum == 2) { prepareMyView2(); } else if (pageNum == 3) { prepareMyView3(); } } } private void prepareMyView1() // each is like this setting adapter on ListView { setMyList1Adapter(); } private void prepareMyView2() // each is like this setting adapter on ListView { setMyList2Adapter(); }
So, I want the changes to addFooterView to be implemented | immediately visible.