title: Android custom listview not clickable on item select
body: <p>I am working with custom listView in android. but I cant able click the item in listview.</p>
  
  <p>my code is</p>
  
  <p>Adapter code(BankArrayListAdapter.java)</p>
  
  <pre><code>package com.example.customlist;
  
  import java.util.List;
  
  import android.content.Context;
  import android.graphics.drawable.Drawable;
  import android.text.method.LinkMovementMethod;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  public class BankArrayListAdapter extends ArrayAdapter&lt;Bank&gt;{
  
      private int resource;
      private LayoutInflater inflater;
      private Context ctx;
  
      public BankArrayListAdapter(Context context, int resourceId, List&lt;com.example.customlist.Bank&gt; ls)
  
  
  
      {
          super(context, resourceId, ls);
  
           resource = resourceId;
  
           inflater = LayoutInflater.from( context );
           ctx=context;
  
          // TODO Auto-generated constructor stub
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      {
  
  
             /* create a new view of my layout and inflate it in the row */
          convertView = inflater.inflate( resource, null );
  
          /* Extract the city's object to show */
          Bank bank = (Bank) getItem(position);
  
          /* Take the TextView from layout and set the city's name */
          TextView txtName = (TextView) convertView.findViewById(R.id.textView1);
          txtName.setText(bank.getName());
  
          /* Take the TextView from layout and set the city's wiki link */
          TextView txtWiki = (TextView) convertView.findViewById(R.id.textView2);
          txtWiki.setTextSize(13);
          txtWiki.setMovementMethod(LinkMovementMethod.getInstance());
           txtWiki.setText(bank.getUrl());
  
          /* Take the ImageView from layout and set the city's image */
          ImageView imageCity = (ImageView) convertView.findViewById(R.id.imageView1);
          String uri = "drawable/" + bank.getLogo();
          int imageResource = ctx.getResources().getIdentifier(uri, null, ctx.getPackageName());
          Drawable image = ctx.getResources().getDrawable(imageResource);
          imageCity.setImageDrawable(image);
  
  
          return convertView;
      }
  
  
  
  }
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.example.customlist;
  
  
  
  import java.util.ArrayList;
  import java.util.List;
  
  
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ListView;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.widget.AdapterView.OnItemClickListener;
  
  public class Main extends Activity {
  
  
      ListView lv;
      List&lt;Bank&gt; ls;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          lv= (ListView) findViewById(R.id.listView1);
  
  
          ls= new ArrayList&lt;Bank&gt;();
  
  
  
           ls.add(new Bank("sbi","State Bank Of India","http://www.sbi.com"));
  
  
          ls.add(new Bank("iob", "India Overseas Bank","http://www.iob.com"));
  
          ls.add(new Bank("icici","ICICI","http://www.icici.com"));
  
  
  
  
          //lv.setAdapter( new BankArraylistA);
          lv.setAdapter( new BankArrayListAdapter(Main.this, R.layout.banklist, ls ) );
  
          lv.setOnItemClickListener(new OnItemClickListener() {
              @Override
                 public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) {
  
                     Toast.makeText(Main.this,"Your Listener Works!",Toast.LENGTH_SHORT).show();
                     // System.out.println("Name: "+ls.get(position).getName());
                    // String s =(String) ((TextView) v.findViewById(R.id.From)).getText();
                    // Toast.makeText(Messages.this, s, Toast.LENGTH_LONG).show();  
                 }
         });
  
  
          System.out.println(ls);
  
  
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>activity_main.xml file goes like this</p>
  
  <pre><code>&lt;LinearLayout 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"
      android:descendantFocusability="blocksDescendants"
      tools:context=".Main" &gt;
  
      &lt;ListView
          android:id="@+id/listView1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
           &gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p>Regards,
  Sathish</p>