title: In a fragment implementation, the ListView below EditText disappears after setting keypad element (of EditText view) to hide
body: <p><a href="http://i.stack.imgur.com/CYdma.png" rel="nofollow">this is image while useing keypad   </a></p>
  
  <p><a href="http://i.stack.imgur.com/CAdlA.png" rel="nofollow">and this image after keypad was hidden   </a></p>
  
  <p>I use <code>EditText</code> but below it there is <code>ListView</code>. After typing text inputs in <code>EditText</code> and then press done or click back to hide keypad. Then the part of <code>ListView</code> behind the keypad disappeared and replaced by white area (cleared), why ?</p>
  
  <p>NOTE: this fragment is under tablayout and viewpager and the fragment which contain the edit text and listview is launched from the main fragment
  this is main fragment</p>
  
  <pre><code>    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&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
      private final List&lt;String&gt; mFragmentTitleList = new ArrayList&lt;&gt;();
  
      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);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>this is xml of main fragment </p>
  
  <pre><code>    &lt;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"
  &gt;
  
  
  &lt;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"&gt;
      &lt;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"&gt;
  
          &lt;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"
              /&gt;
  
      &lt;/RelativeLayout&gt;
  
  
      &lt;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"/&gt;
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;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"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>the fragment which contain listview and edit text</p>
  
  <pre><code>    public class FindFriendsFragment extends Fragment {
  
      public FindFriendsFragment()
      {
          // Required empty public constructor
      }
      ListView myfriends_list;
      FindFriendsAdapter adapter;
      ArrayList&lt;FindFriends&gt; 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&lt;FindFriends&gt;();
          arraylist.add(new FindFriends("mina fared", "hello     
              guys",1,"sdsdsdsds",true )) ;
  
          adapter = new FindFriendsAdapter(getActivity(), arraylist);
  
          myfriends_list.setAdapter(adapter);
          adapter.notifyDataSetChanged();
  
  
          return rootview;
      }
  
    }
  </code></pre>
  
  <p>And the related xml file is of the fragment which contain listview and edittext:</p>
  
  <pre><code>&lt;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"
    &gt;
  
  
  
  &lt;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"
      &gt;
  
      &lt;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"
  
  
          /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;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"
       /&gt;
  
  
     &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>this is the parent fragment which contains all fragments</p>
  
  <pre><code>    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;
    }
  </code></pre>
  
  <p>}</p>