title: setOnItemClickListener not working
body: <p>My Listview app gets its data and background color of itemview from custom adapter <code>ListAdapter.class</code>.i also need to set the currently selected list items value in a <code>textview</code> below <code>listview</code>,but the <code>setOnItemClickListener</code> in <code>MAinActivity</code> is not executing.pls help.</p>
  
  <p>This is my list view app:</p>
  
  <p><a href="https://i.stack.imgur.com/lw0sG.png" rel="nofollow noreferrer">Layout image</a></p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  private static ListAdapterclass adapter;
      ListView lv;
      TextView tv2;
      private  final String android_versions[]={
              "Donut",
              "Eclair",
              "Froyo",
              "Gingerbread",
              "Honeycomb",
              "Ice Cream Sandwich",
              "Jelly Bean",
              "KitKat",
              "Lollipop",
              "Marshmallow"
      };
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          initViews();
      }
      private  void initViews() {
          lv = (ListView) findViewById(R.id.listView1);
          tv2 = (TextView) findViewById(R.id.selected);
  
          adapter = new ListAdapterclass(getApplicationContext(), android_versions);
          lv.setAdapter(adapter);
          lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                  Toast.makeText(getApplicationContext(), "hiiiiiiiii", Toast.LENGTH_SHORT).show();
                  System.out.println("********************** INSIDE  ONITEMCLICKLISTNER IN MAIN ACTIVITY ******************");
                  String ver_name = (lv.getItemAtPosition(i)).toString();
  
  
                  tv2 = (TextView) findViewById(R.id.selected);
                  tv2.setText(ver_name);
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>ListAdapter.class</strong></p>
  
  <pre><code>public class ListAdapterclass extends ArrayAdapter implements AdapterView.OnItemClickListener{
  
      private String android_versionNames[];
      Context mContext;
      public int row_index=-1;
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; adapterView, View v, int i, long l) {
          int position=(Integer)v.getTag();
          String ver_name=getItem(position).toString();
      }
  
      private static class ViewHolder{
          TextView tv;
         LinearLayout LL;
          TextView tv2;
      }
  
  
  
      public ListAdapterclass(Context context,String android_versionnames[]) {
          super(context, R.layout.list_item,android_versionnames);
          this.android_versionNames=android_versionnames;
          this.mContext=context;
  
          System.out.println(" ????????????????????????  Inside dataadapter,Android names :  ?????????????????????????????\n  ");
          for(int i=0;i&lt;android_versionnames.length;i++){
              System.out.println("\n"+android_versionnames[i]);
          }
  
      }
      private int lastPosition=-1;
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          String ver_name=getItem(position).toString();
  
          final ViewHolder viewHolder;
          final View result;
  
          if(convertView==null){
              viewHolder=new ViewHolder();
              LayoutInflater inflater=LayoutInflater.from(getContext());
              convertView=inflater.inflate(R.layout.list_item,parent,false);
              viewHolder.tv=(TextView)convertView.findViewById(R.id.label);
              viewHolder.LL=(LinearLayout) convertView.findViewById(R.id.linearLayout_1);
              viewHolder.tv2=(TextView)convertView.findViewById(R.id.selected);
              result=convertView;
              convertView.setTag(viewHolder);
          }else{
              viewHolder=(ViewHolder) convertView.getTag();
              result=convertView;
          }
          lastPosition=position;
  
          viewHolder.tv.setText(ver_name);
  
          viewHolder.LL.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  row_index=position;
                  notifyDataSetChanged();
              }
          });
          if(row_index==position){
              viewHolder.LL.setBackgroundColor(Color.parseColor("#409de1"));
              viewHolder.tv.setTextColor(Color.parseColor("#ffffff"));
          }
          else
          {
              viewHolder.LL.setBackgroundColor(Color.parseColor("#ffffff"));
              viewHolder.tv.setTextColor(Color.parseColor("#000000"));
  
          }
          return convertView;
      }
  }
  </code></pre>
  
  <p><strong>ActivityMain.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
  android:orientation="vertical"
      tools:context="com.cybraum.test.listviewcolorchange.MainActivity"
      &gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
  android:clickable="true"
      android:layout_weight="1"
      &gt;
   &lt;ListView
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:id="@+id/listView1"
       &gt;
   &lt;/ListView&gt;
  
  
  &lt;/LinearLayout&gt;
  
   &lt;LinearLayout
       android:layout_width="match_parent"
       android:layout_height="0dp"
       android:layout_weight=".2"
       android:id="@+id/linearLayout_2"
       android:orientation="horizontal"
  
       &gt;
    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Selected : "
        android:textStyle="bold"
        android:layout_gravity="center"/&gt;
    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:text="text"
        android:id="@+id/selected"
        android:layout_gravity="center"/&gt;
  
   &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>listitem.xml</strong></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_height="wrap_content"
      android:layout_width="fill_parent"
      android:id="@+id/linearLayout_1"
      android:padding="10dp"&gt;
  &lt;TextView
      android:id="@+id/label"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="10dip"
      android:textSize="16dip"
      android:textStyle="bold"
      android:textColor="#000000"
      android:gravity="center"&gt;
  &lt;/TextView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>what is the problem?</p>