title: Issue in setting Textview's text in Custom Adapter for Android
body: <p>I am not able to set textview's setText property inside <code>getView()</code> method of Custom Adapter.</p>
  
  <p>I already tried below solutions but it does not work for me :</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/5612844/how-to-get-a-list-item-position-by-clicking-the-button-inside-it">Solution One</a></li>
  <li><a href="https://stackoverflow.com/questions/20541821/get-listview-item-position-on-button-click">Solution Two</a></li>
  <li><a href="https://stackoverflow.com/questions/22602517/custom-list-adapter-not-binding-values-to-textview">Solution Three</a></li>
  </ul>
  
  <p>Listview.xml file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/imgLayout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;ListView
      android:id="@+id/list"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="40dp"
      android:divider="@null"
      android:dividerHeight="5dp"
      android:scrollbars="none" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Below is my keep_resing xml file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/customRowLayout"
  android:layout_width="fill_parent"
  android:layout_height="60dp"
  android:layout_marginTop="20dp"
  android:orientation="horizontal" &gt;
  
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" &gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:orientation="vertical" &gt;
  
          &lt;ImageButton
              android:id="@+id/Btn"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_marginLeft="10dp"
              android:background="@drawable/thumb_down_disabled" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:gravity="center_horizontal"
              android:text="@string/resing"
              android:textColor="#357EC7"
              android:textSize="10sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:orientation="vertical" &gt;
  
          &lt;TextView
              android:id="@+id/lyricsTxt"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal" /&gt;
  
          &lt;RelativeLayout
              android:id="@+id/parentLayout"
              android:layout_width="120dp"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:layout_marginTop="5dp"
              android:background="@drawable/playing_view"
              android:orientation="horizontal" &gt;
  
              &lt;TextView
                  android:id="@+id/helloTxt"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerInParent="true"
                  android:layout_marginLeft="5dp"
                  android:singleLine="true"
                  android:text="Hello"
                  android:textColor="#357EC7"
                  android:textSize="14sp" /&gt;
  
              &lt;ImageView
                  android:layout_width="20dp"
                  android:layout_height="20dp"
                  android:layout_alignParentRight="true"
                  android:layout_centerVertical="true"
                  android:layout_marginRight="5dp"
                  android:background="@drawable/volume" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:orientation="vertical" &gt;
  
          &lt;ImageButton
              android:id="@+id/keepBtn"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_marginRight="10dp"
              android:background="@drawable/thumb_up_disabled" /&gt;
  
          &lt;TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:gravity="center_horizontal"
              android:text="@string/keep"
              android:textColor="#357EC7"
              android:textSize="10sp" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Below is my adapter code :</p>
  
  <pre><code>import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  import org.simpleframework.xml.stream.Position;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.res.AssetFileDescriptor;
  import android.content.res.Resources;
  import android.media.MediaPlayer;
  import android.media.MediaPlayer.OnCompletionListener;
  import android.os.Handler;
  import android.os.PowerManager;
  import android.sax.StartElementListener;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.ImageButton;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class KeepReSingAdapter extends BaseAdapter implements OnClickListener {
  
      /*********** Declare Used Variables *********/
      private Activity activity;
      private ArrayList data;
      private static LayoutInflater inflater = null;
      public Resources res;
      SongCue tempValues = null;
      int i = 0;
  
      private ArrayList&lt;SongCue&gt; songCue;
      private int cueIndex = 0;
      private String selectedSongId;
      private MediaPlayer mMediaPlayer;
      ViewHolder holder;
      View vi;
      boolean right_button_flag, left_button_flag;
      SessionManager session;
  
      // int left_button_flag;
  
      /************* CustomAdapter Constructor *****************/
      public KeepReSingAdapter(Activity a, ArrayList d, Resources resLocal) {
  
          /********** Take passed values **********/
          activity = a;
          data = d;
          res = resLocal;
  
          /*********** Layout inflator to call external xml layout () ***********/
          inflater = (LayoutInflater) activity
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
  
  
          selectedSongId = SessionManager.getInstance(
                  activity.getApplicationContext()).getString(
                  AppConstants.SONG_ID);
  
          right_button_flag = false;
          left_button_flag = false;
  
          // Session class instance
          session = new SessionManager(activity.getApplicationContext());
  
      }
  
      /******** What is the size of Passed Arraylist Size ************/
      public int getCount() {
  
          if (data.size() &lt;= 0)
              return 1;
          return data.size();
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      /********* Create a holder Class to contain inflated xml file elements *********/
      public static class ViewHolder {
  
          public TextView lyricsTxt, helloTxt;
          // public TextView text1;
          public ImageButton leftBtn, rightBtn;
          public RelativeLayout parentLayout;
          public LinearLayout rowLayout;
  
          // public TextView textWide;
          // ImageView image;
  
      }
  
      /****** Depends upon data size called for each row , Create each ListView row *****/
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          vi = convertView;
  
          if (convertView == null) {
  
              vi = inflater.inflate(R.layout.keep_resing, null);
  
              holder = new ViewHolder();
              holder.lyricsTxt = (TextView) vi.findViewById(R.id.lyricsTxt);
              holder.helloTxt = (TextView) vi.findViewById(R.id.helloTxt);
  
              holder.leftBtn = (ImageButton) vi.findViewById(R.id.reSingBtn);
              holder.rightBtn = (ImageButton) vi.findViewById(R.id.keepBtn);
              holder.parentLayout = (RelativeLayout) vi
                      .findViewById(R.id.parentLayout);
              holder.rowLayout = (LinearLayout) vi
                      .findViewById(R.id.customRowLayout);
  
  
  
  
  
              vi.setTag(holder);
  
          } else {
              holder = (ViewHolder) vi.getTag();
  
          }
  
          if (data.size() &lt;= 0) {
  
  
  
          } else {
              /***** Get each Model object from Arraylist ********/
              tempValues = null;
              tempValues = (SongCue) data.get(position);
  
  
              holder.lyricsTxt.setText(tempValues.getLyric());
  
              List&lt;Song&gt; AllSong = SplashScreen_Activity.songs;
              if (selectedSongId != null) {
                  for (Song tempsong : AllSong) {
                      if (tempsong.songId.equals(selectedSongId)) {
                          songCue = (ArrayList&lt;SongCue&gt;) tempsong.songCues.songCue;
                      }
                  }
              } else {
  
              }
  
  
  
  
              holder.parentLayout.setOnClickListener(new View.OnClickListener() {
  
                 @Override
                 public void onClick(View v) {
  
                  Toast.makeText(activity.getApplicationContext(),
                          " " + position, Toast.LENGTH_SHORT).show();
  
                       holder.helloTxt.setText("Test");
  
                      Toast.makeText(activity.getApplicationContext(),
                              holder.helloTxt.getText().toString(),
                              Toast.LENGTH_LONG).show();
  
  
                     }
                 });
  
  
  
          }
          vi.setOnClickListener(new OnItemClickListener(position));
          return vi;
      }
  
  
      @Override
      public void onClick(View v) {
          Log.v("CustomAdapter", "=====Row button clicked=====");
  
      }
  
      /********* Called when Item click in ListView ************/
      private class OnItemClickListener implements OnClickListener {
          private int mPosition;
  
          OnItemClickListener(int position) {
              mPosition = position;
          }
  
          @Override
          public void onClick(View arg0) {
  
  
          }
      }
  
  }
  </code></pre>
  
  <p>Problem is, I am not able to change the text view text to "Test".</p>
  
  <p><strong>Note</strong> : If I see the value in Toast by doing "<code>holder.helloTxt.getText().toString()</code>" it shows me "<strong><em>Test</em></strong>".</p>
  
  <p>I don't know why this problem is arising.Any help will be highly appreciated.</p>
  
  <p>Thanks</p>