title: Buttons Missing When Scroll the ListView
body: <p>when i click the listview item, that particular item button is Visible. when i scroll the listview the buttons are gone. how to implement this functionality. what is the wrong in this please help me. Thanks</p>
  
  <p>Here is My Code:</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      ListView lv;
      SampleAdapter sa;
      ArrayList&lt;String&gt; as=new ArrayList&lt;String&gt;();
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          for(int i=0;i&lt;20;i++)
          {
              as.add(String.valueOf(i));
          }
          lv=(ListView)findViewById(R.id.listView1);
          sa=new SampleAdapter(MainActivity.this);
          lv.setAdapter(sa);
  
          }
      class SampleAdapter extends BaseAdapter
      {
  
          Context ctx;
          Button b;
          TextView tv;
          LayoutInflater lin;
          public SampleAdapter(Context ct) {
              this.ctx=ct;
          }
  
          @Override
          public int getCount() {
              // TODO Auto-generated method stub
              return as.size();
          }
  
          @Override
          public Object getItem(int arg0) {
              // TODO Auto-generated method stub
              return arg0;
          }
  
          @Override
          public long getItemId(int arg0) {
              // TODO Auto-generated method stub
              return arg0;
          }
  
          @Override
          public View getView(int pos, View arg1, ViewGroup arg2) {
              // TODO Auto-generated method stub
              lin=(LayoutInflater)ctx.getSystemService(LAYOUT_INFLATER_SERVICE);
              arg1=lin.inflate(R.layout.li, null);
              tv=(TextView)arg1.findViewById(R.id.textView1);
              b=(Button)arg1.findViewById(R.id.button1);
              tv.setText(as.get(pos));
              b.setText(as.get(pos));
              arg1.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      Button c=(Button)v.findViewById(R.id.button1);
                      c.setVisibility(View.VISIBLE);
                  }
              });
              return arg1;
          }
  
      }
      }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;ListView
          android:id="@+id/listView1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1" &gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>li.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="TextView" /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:visibility="invisible"
          android:text="Button" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>