title: Listview getting refreshed after scrolling the list in android
body: <p>thanks in advance , please forgive me if I am mistaking somewhere when explaining the question</p>
  
  <p>I have a Listview and a custom ArrayAdapter and the layout for the custom ArrayAdapter is as follows.</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_marginLeft="48dp"
      android:layout_marginTop="14dp"
      android:text="Medium Text"
      android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/textView1"
      android:layout_alignBottom="@+id/textView1"
      android:layout_alignParentRight="true"
      android:layout_marginRight="43dp"
      android:text="Button" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and the custom array adapter java code is as follows.</p>
  
  <pre><code>public class CustomArrayAdapter extends ArrayAdapter&lt;String&gt;{
  
  Context context;
  ArrayList&lt;String&gt; list=new ArrayList&lt;String&gt;();
  public CustomArrayAdapter(Context con,ArrayList&lt;String&gt; data) {
      // TODO Auto-generated constructor stub
      super(con,R.layout.adapter_layout,data);
      this.context=con;
      this.list=data;
  
  }
  
  @Override
  public View getView(int postion, View arg1, ViewGroup parent) {
      // TODO Auto-generated method stub
      //LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      //View view=inflater.inflate(R.layout.adapter_layout, parent,false);
  
      Myclass item=new Myclass(context);
  
      /*TextView tv=(TextView)view.findViewById(R.id.textView1);
      Button button=(Button)view.findViewById(R.id.button1);
      item.SetContextForTextView(tv,list.get(postion));
  
      item.SetContextForTheButton(button);
      tv.setText(list.get(postion));*/
      item.setView();
      //item.setText(list.get(postion));
  
  
  
      return item.getView();
  }
  
  }
  </code></pre>
  
  <p>Since i have created a separate object of Myclass for every item of the list view the code for the Myclass is given below.</p>
  
  <pre><code>public class Myclass {
  TextView tv;
  Button button;
  Context context;
  View view;
  LayoutInflater inflater;
  public Myclass(Context con)
  {
      context=con;
  }
  public void setText(String text)
  {
      this.tv.setText(text);
  }
  public String getText()
  {
      return this.tv.getText().toString();
  }
  
  public void SetContextForTextView(TextView text,String data)
  {
      tv=text;
      setText(data);
  }
  public void SetContextForTheButton(Button btn)
  {
      button=btn;
      button.setOnClickListener(button_click);
  }
  
  public OnClickListener button_click=new OnClickListener() {
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
          setText("hi...");
  
      }
  };
  
  public void setView()
  {
      inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view=inflater.inflate(R.layout.adapter_layout,null);
      tv=(TextView)view.findViewById(R.id.textView1);
      button=(Button)view.findViewById(R.id.button1);
      button.setOnClickListener(button_click);
  
  }
  
  public View getView()
  {
      return view;
  }
  
  
  
  }
  </code></pre>
  
  <p>since on the button click on the every list item I am updating the text of the TextView to "hi..." it works perfectly but when i am scrolling the updated result get refreshed.</p>
  
  <p>I had searched a lot on this but cant found the answer .</p>
  
  <p>Please little help in this matter would be appreciable. </p>
  
  <p>before scrolling the result look like this</p>
  
  <p><img src="https://i.stack.imgur.com/mDFHx.png" alt="enter image description here"></p>
  
  <p>and after scrolling result look like this</p>
  
  <p><img src="https://i.stack.imgur.com/wKyMi.png" alt="enter image description here"></p>