android - TabLayout changing to fully black -


i have created tabs using tablayout. when changing tabs front , back, in middle tab, whole tab layout becomes black. else working fine when first or last tab, again shows perfectly. in middle tab creating problem.

same code 2 tabs working perfectly.

only 3 tab , in centre of these 3 tabs creates problem.

when in first tab

when in first tab

when in second (middle) tab

when in second (middle) tab

android layout

<linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <android.support.design.widget.tablayout         android:id="@+id/sliding_tabs"         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:tabmode="fixed" />      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="0px"         android:layout_weight="1"         android:background="@android:color/white" /> </linearlayout> 

pageadapter

public class aboutpageadapter extends fragmentpageradapter {     final int page_count = 3;     private string tabtitles[] = new string[]{"phaseshift", "core committee", "team"};     private context context;      public aboutpageadapter(fragmentmanager fm, context context) {         super(fm);         this.context = context;     }      @override     public fragment getitem(int position) {         if (position == 0) {             return new aboutphaseshiftfragment();         } else if (position == 1) {             return new aboutcorecommitteefragment();         } else {             return new aboutappwebteamfragment();         }     }      @override     public int getcount() {         return page_count;     }      @override     public charsequence getpagetitle(int position) {         // generate title based on item position         return tabtitles[position];     } } 

aboutcorecommitteefragment

public class aboutcorecommitteefragment extends fragment {     // todo: rename parameter arguments, choose names match     // fragment initialization parameters, e.g. arg_item_number     private static final string arg_param1 = "param1";     private static final string arg_param2 = "param2";      // todo: rename , change types of parameters     private string mparam1;     private string mparam2;      private onfragmentinteractionlistener mlistener;      public aboutcorecommitteefragment() {         // required empty public constructor     }      /**      * use factory method create new instance of      * fragment using provided parameters.      *      * @param param1 parameter 1.      * @param param2 parameter 2.      * @return new instance of fragment aboutcorecommitteefragment.      */     // todo: rename , change types , number of parameters     public static aboutcorecommitteefragment newinstance(string param1, string param2) {         aboutcorecommitteefragment fragment = new aboutcorecommitteefragment();         bundle args = new bundle();         args.putstring(arg_param1, param1);         args.putstring(arg_param2, param2);         fragment.setarguments(args);         return fragment;     }      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         if (getarguments() != null) {             mparam1 = getarguments().getstring(arg_param1);             mparam2 = getarguments().getstring(arg_param2);         }     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         // inflate layout fragment         view rootview = inflater.inflate(r.layout.fragment_about_core_committee, container, false);          arraylist<person> corelist = new arraylist<>();  //        code hidden          listview listview = (listview) rootview.findviewbyid(r.id.corecommitteelist);         personadapter contactcoreadapter = new personadapter(getcontext(), corelist);         listview.setadapter(contactcoreadapter);          return rootview;     }      // todo: rename method, update argument , hook method ui event     public void onbuttonpressed(uri uri) {         if (mlistener != null) {             mlistener.onfragmentinteraction(uri);         }     }      @override     public void onattach(context context) {         super.onattach(context);         if (context instanceof onfragmentinteractionlistener) {             mlistener = (onfragmentinteractionlistener) context;         } else {             throw new runtimeexception(context.tostring()                     + " must implement onfragmentinteractionlistener");         }     }      @override     public void ondetach() {         super.ondetach();         mlistener = null;     }      /**      * interface must implemented activities contain      * fragment allow interaction in fragment communicated      * activity , potentially other fragments contained in      * activity.      * <p>      * see android training lesson <a href=      * "http://developer.android.com/training/basics/fragments/communicating.html"      * >communicating other fragments</a> more information.      */     public interface onfragmentinteractionlistener {         // todo: update argument type , name         void onfragmentinteraction(uri uri);     } } 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -