title: Listview item disappear in custom view while scrolling or click of editText -Android
body: <p>Custom list view Item disappear While scrolling or click of edit text.</p>
  
  <p>Main class where  custom adater value is bind to list</p>
  
  <pre><code>package com.example.customlistview;
  import java.util.ArrayList;
  import android.os.Bundle;
  import android.app.Activity;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  public class MainActivity extends Activity {
      ArrayList&lt;String&gt; nameList;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          try {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
              ListView list = (ListView)findViewById(R.id.listView1);
              nameList = new ArrayList&lt;String&gt;(); 
              nameList.add("Iphone");
              nameList.add("Android");
              nameList.add("Samsung");
              nameList.add("BlackBery");
              nameList.add("Lava");
              nameList.add("T Mobile");
              nameList.add("Lg Mobile");
              CustomAdapter adapter = new CustomAdapter(this,nameList);
              list.setAdapter(adapter);
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }      
      }
  }
  </code></pre>
  
  <p>Custom Adapter class .This class creating view to bind on list</p>
  
  <pre><code>        package com.example.customlistview;
          import java.util.ArrayList;
          import android.content.Context;
          import android.view.LayoutInflater;
          import android.view.View;
          import android.view.ViewGroup;
          import android.widget.ArrayAdapter;
          import android.widget.TextView;
  
          public class CustomAdapter extends  ArrayAdapter&lt;String&gt; {
              TextView name;
              TextView add;
              TextView state;
              public Context context;
              ArrayList&lt;String&gt; List;
              View rowView;
              String str1,str2,str3;
              public CustomAdapter(Context context, ArrayList&lt;String&gt; nameList) {
                  super(context, 0,nameList);
                  List = nameList;
                  this.context = context;
              }
              @SuppressWarnings("null")
              @Override
              public View getView(int position, View convertView, ViewGroup parent) {
  
                  try {
                      str1 = List.get(position);
                      str2 = List.get(position);
                      str3 = List.get(position);
                  } catch (Exception e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                  }
                  if( convertView==null){
                      LayoutInflater inflater = (LayoutInflater) context
                              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                       rowView = inflater.inflate(R.layout.customlayout, parent, false);
                       TextView name = (TextView) rowView.findViewById(R.id.nameT);   
                       TextView add= (TextView) rowView.findViewById(R.id.addT);          
                       TextView state = (TextView) rowView.findViewById(R.id.stateT);
                      if(name != null) {
                          try {
                              name.setVisibility(View.VISIBLE);  
                              name.setText(str1);
                          } catch (Exception e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                          }   
                      }else {
  
                          name.setVisibility(View.INVISIBLE); 
                      }
                      if(add != null) {
                          add.setVisibility(View.VISIBLE); 
                          add.setText(str2);;
  
                      }else {
                          add.setVisibility(View.INVISIBLE); 
                      }
                      if(state != null) {
                          state.setVisibility(View.VISIBLE);
                          state.setText(str3);;
                      }else {
                          state.setVisibility(View.INVISIBLE); 
                      }
                  }
                  return rowView;
  
              }
  
          }
  </code></pre>
  
  <p>The Main Xml is</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_alignParentLeft="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:orientation="vertical" &gt;
  
          &lt;EditText
              android:id="@+id/editText1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentRight="true"
              android:layout_alignParentTop="true"
              android:ems="10" &gt;
  
              &lt;requestFocus /&gt;
          &lt;/EditText&gt;
  
          &lt;ListView
              android:id="@+id/listView1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_alignParentLeft="true"
              android:layout_marginTop="10dp"
              android:layout_weight="1.67"
              android:cacheColorHint="#00000000" &gt;
          &lt;/ListView&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The Custom Xml is</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="80dp" &gt;
              &lt;TextView
              android:id="@+id/nameT"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:text="TextView" /&gt;
  
          &lt;TextView
              android:id="@+id/addT"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/nameT"
              android:layout_marginLeft="60dp"
              android:layout_toRightOf="@+id/nameT"
              android:text="TextView" /&gt;
  
  
  
          &lt;TextView
              android:id="@+id/stateT"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="40dp"
              android:layout_marginRight="38dp"
              android:text="TextView" /&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Before click of edit text ---><a href="http://i1167.photobucket.com/albums/q626/NomanKhan000777/559a7570.png" rel="nofollow">First Image</a> .After click of edit text ---> <a href="http://i1167.photobucket.com/albums/q626/NomanKhan000777/7ca489b7.png" rel="nofollow">Second Image</a>. </p>
  
  <p>And finally when virtual keyboard down only one item shows in list</p>