android - In a fragment implementation, the ListView below EditText disappears after setting keypad element (of EditText view) to hide -


this image while useing keypad

and image after keypad hidden

i use edittext below there listview. after typing text inputs in edittext , press done or click hide keypad. part of listview behind keypad disappeared , replaced white area (cleared), why ?

note: fragment under tablayout , viewpager , fragment contain edit text , listview launched main fragment main fragment

    public class friendsfragment extends fragment {  public friendsfragment() {     // required empty public constructor } private fragmentactivity mycontext;  private toolbar toolbar; private tablayout tablayout; private viewpager viewpager;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate); } @override public void onattach(activity activity) {     mycontext=(fragmentactivity) activity;     super.onattach(activity); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {    view rootview=inflater.inflate(r.layout.friends_fragment, container, false);       viewpager = (viewpager) rootview.findviewbyid(r.id.viewpager);     setupviewpager(viewpager);      tablayout = (tablayout) rootview.findviewbyid(r.id.tabs);     tablayout.setupwithviewpager(viewpager);      tablayout.setupwithviewpager(viewpager);      tablayout.setontabselectedlistener(             new tablayout.viewpagerontabselectedlistener(viewpager) {                 @override                 public void ontabselected(tablayout.tab tab) {                     super.ontabselected(tab);                      if (tab.getposition() == 1) {                         findfriendsfragment.myfriends_list.invalidate(findfriendsfragment.myfriends_list.getleft(), findfriendsfragment.myfriends_list.gettop(), findfriendsfragment.myfriends_list.getright(), findfriendsfragment.myfriends_list.getbottom());                         findfriendsfragment.adapter.notifydatasetchanged();                         findfriendsfragment.myfriends_list.clearfocus();                         findfriendsfragment.myfriends_list.postinvalidate();                     }                   }             });          textview friends = (textview) rootview.findviewbyid(r.id.search);     typeface exo_thin = typeface.createfromasset(mycontext.getassets(), "fonts/exo2.0-thin.otf");     friends.settypeface(exo_thin);       return rootview;   } private void setupviewpager(viewpager viewpager) {     viewpageradapter adapter = new viewpageradapter(getchildfragmentmanager());      adapter.addfragment(new myfriendsfragment(), "my friends");     adapter.addfragment(new findfriendsfragment(), "find friends");      adapter.addfragment(new twofragment(), "friend requests");     viewpager.setadapter(adapter); }  class viewpageradapter extends fragmentstatepageradapter {     private final list<fragment> mfragmentlist = new arraylist<>();     private final list<string> mfragmenttitlelist = new arraylist<>();      public viewpageradapter(fragmentmanager manager) {         super(manager);     }      @override     public fragment getitem(int position) {         return mfragmentlist.get(position);     }      @override     public int getcount() {         return mfragmentlist.size();     }      public void addfragment(fragment fragment, string title) {         mfragmentlist.add(fragment);          mfragmenttitlelist.add(title);     }      @override     public charsequence getpagetitle(int position) {         return mfragmenttitlelist.get(position);     } } 

}

this xml of main fragment

    <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:clickable="true" android:layout_width="match_parent" android:layout_height="match_parent" >   <android.support.design.widget.appbarlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"      android:textallcaps="false"     android:theme="@style/themeoverlay.appcompat.dark.actionbar">     <relativelayout         android:layout_height="match_parent"         android:layout_width="match_parent"         android:orientation="vertical"         android:id="@+id/rel"         android:layout_alignparenttop="true"          android:weightsum="1">          <textview             android:layout_width="match_parent"             android:layout_height="60dp"             android:id="@+id/search"             android:text="friends"             android:layout_marginleft="10dp"             android:gravity="center_vertical"             android:textsize="25sp"              android:textcolor="@color/colorverydarkblue"             />      </relativelayout>       <android.support.design.widget.tablayout         android:id="@+id/tabs"         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:tabtextappearance="@android:style/textappearance.widget.tabwidget"         app:tabselectedtextcolor="@color/colorlightgreen"         app:tabtextcolor="@color/colordarkgreen"          app:tabmode="scrollable"          android:background="@color/colordarkblue"          app:tabindicatorcolor="@color/colordarkblue"          app:tabgravity="center"/> </android.support.design.widget.appbarlayout>  <android.support.v4.view.viewpager     android:id="@+id/viewpager"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

the fragment contain listview , edit text

    public class findfriendsfragment extends fragment {      public findfriendsfragment()     {         // required empty public constructor     }     listview myfriends_list;     findfriendsadapter adapter;     arraylist<findfriends> arraylist ;       @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate)     {         view rootview= inflater.inflate(r.layout.find_friends_fragment, container, false);        edittext search=(edittext) rootview.findviewbyid(r.id.search);          typeface exo_regular =              typeface.createfromasset(getactivity().getassets(), "fonts/exo2.0-           regular.otf");         search.settypeface(exo_regular);         arraylist = new arraylist<findfriends>();         arraylist.add(new findfriends("mina fared", "hello                  guys",1,"sdsdsdsds",true )) ;          adapter = new findfriendsadapter(getactivity(), arraylist);          myfriends_list.setadapter(adapter);         adapter.notifydatasetchanged();           return rootview;     }    } 

and related xml file of fragment contain listview , edittext:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" android:background="#ffffff"   >    <linearlayout     android:layout_height="60dp"     android:layout_width="match_parent"     android:orientation="vertical"     android:layout_margintop="111dp"     android:id="@+id/refl"     android:background="@color/colorlightgrey"     android:layout_alignparenttop="true"     >      <edittext         android:layout_width="match_parent"         android:layout_height="40dp"          android:id="@+id/search"         android:layout_marginright="15dp"         android:layout_marginleft="15dp"         android:background="#ffffff"         android:singleline="true"          android:hint="search"         android:ellipsize="start"         android:imeoptions="actiondone"         android:gravity="center_vertical|center_horizontal"          android:layout_margintop="10dp"         android:textsize="15sp"         android:textcolorhint="@color/colormyhintfindfiernds"         android:textcolor="@color/colordarkblue"           />  </linearlayout>  <listview     android:id="@+id/listview"      android:layout_width="match_parent"     android:layout_height="match_parent"       android:background="#ffffff"     android:layout_margintop="1dp"     android:layout_below="@+id/refl"     android:divider="#ffffff"     android:dividerheight="1.5dp"      />      </relativelayout> 

this parent fragment contains fragments

    public class profilefragment extends fragment {  public profilefragment() {     // required empty public constructor } relativelayout rl1; drawview drawview ; drawview  drawview2; textview myprofile,username,notification_txt,colloection_txt,friends_txt,setting_txt,public_profile_txt; imageview public_profile_btn,friends; @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate); }  @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {    view rootview=inflater.inflate(r.layout.myprofile_fragment, container,       false);       username= (textview) rootview.findviewbyid(r.id.user_name_txt);     myprofile= (textview) rootview.findviewbyid(r.id.myprofile);     notification_txt= (textview) rootview.findviewbyid(r.id.notification_txt);     colloection_txt= (textview) rootview.findviewbyid(r.id.colloection_txt);     friends_txt= (textview) rootview.findviewbyid(r.id.friends_txt);     setting_txt= (textview) rootview.findviewbyid(r.id.setting_txt);     public_profile_txt= (textview) rootview.findviewbyid(r.id.public_profile_txt);       typeface exo_thin = typeface.createfromasset(getactivity().getassets(), "fonts/exo2.0-thin.otf");     typeface exo_semibold = typeface.createfromasset(getactivity().getassets(), "fonts/exo2.0-semibold.otf");      myprofile.settypeface(exo_thin);     username.settypeface(exo_semibold);     notification_txt.settypeface(exo_semibold);     colloection_txt.settypeface(exo_semibold);     friends_txt.settypeface(exo_semibold);     setting_txt.settypeface(exo_semibold);     public_profile_txt.settypeface(exo_semibold);      imageview x=(imageview)rootview.findviewbyid(r.id.colloection);     imageview y=(imageview)rootview.findviewbyid(r.id.friends);     imageview x1=(imageview)rootview.findviewbyid(r.id.setting);     rl1 =(relativelayout)rootview.findviewbyid(r.id.rel2);      final view fragmentcontainer = rootview.findviewbyid(r.id.container);        friends  =(imageview)rootview.findviewbyid(r.id.friends);       public_profile_btn=(imageview)rootview.findviewbyid(r.id.public_profile);       public_profile_btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view)         {               fragment newfragment = new myprofilefragment();             fragmenttransaction transaction = getfragmentmanager().begintransaction();             transaction.replace(fragmentcontainer.getid(), newfragment);               transaction.addtobackstack(null);             transaction.commit();          }     });      friends.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view)         {               fragment newfragment = new friendsfragment();             fragmenttransaction transaction = getfragmentmanager().begintransaction();             transaction.replace(fragmentcontainer.getid(), newfragment);              transaction.addtobackstack(null);             transaction.commit();          }     });       return rootview;   } 

}

from manifest.xml search activity tag

<activity         android:name=".youractivity"         android:label="@string/title_activity"         ...> </activity> 

then add android:configchanges="keyboard|keyboardhidden"

<activity         android:name=".youractivity"         android:configchanges="keyboard|keyboardhidden"         android:label="@string/title_activity"         ...> </activity> 

edit

i found answer not right may add

android:windowsoftinputmode="adjustnothing" 

sorry


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -