title: onClickListener for buttons inside the onItemClickListener of listview not working before item click
body: <p>I have a <code>listview</code> in android that displays person information from Database.
  The <code>listview</code> is given an <code>OnItemClickListener()</code>  .  Inside the OnItemClickListener() I have also added few <code>onClickListener()</code> for the buttons  in the listview item.  On running the application , the buttons in the listview are not clickable or the <code>OnClickListener()</code> assigned for the buttons are not getting fired. <strong>This issue will no longer appear , once the item in the listview is clicked.All the button click listeners are working after that.</strong>
                          Can somebody give me a solution for this.The code I am using is the follows.</p>
  
  <pre><code>                    listView.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              int listrowposition = arg2;
              HashMap&lt;String, String&gt; item = (HashMap&lt;String, String&gt;) arg0
                      .getAdapter().getItem(arg2);
              final String id = item.get("ID");
              Button vd = (Button) arg1.findViewById(R.id.viewDetails);
              // this onclick listener is not working bfore the onitemclick
              // listener
              vd.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View arg0) {
  
                      Toast.makeText(getApplicationContext(),
                              "view details clicked  Id  " + id,
                              Toast.LENGTH_LONG).show();
                  }
              });
              Button gd = (Button) arg1.findViewById(R.id.getDirections);
              // this onclick listener is not working bfore the onitemclick
              // listener
              gd.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View arg0) {
  
                      Toast.makeText(getApplicationContext(),
                              "getDirections clicked  Id  " + id,
                              Toast.LENGTH_LONG).show();
                  }
              });
              Button ra = (Button) arg1.findViewById(R.id.reqAppointment);
              // this onclick listener is not working bfore the onitemclick
              // listener
              ra.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View arg0) {
  
                      Toast.makeText(getApplicationContext(),
                              "reqAppointment clicked  Id  " + id,
                              Toast.LENGTH_LONG).show();
                  }
              });
  
          }
      });
  </code></pre>
  
  <p>The adapter i am using Is a SimpleAdapter .The adapter details are the follows.</p>
  
  <pre><code>       String[] from = { "flag", "txt", "cur", "viewDet", "getDirect",
              "reqAppnmnt" };
  
      // Ids of views in listview_layout
      int[] to = { R.id.flag, R.id.name, R.id.specialization,
              R.id.viewDetails, R.id.getDirections, R.id.reqAppointment };
  
      // Instantiating an adapter to store each items
      // R.layout.listview_layout defines the layout of each item
      adapter = new SimpleAdapter(getBaseContext(), aList,
              R.layout.listview_layout, from, to);
      new CallToServer(adapter, aList).execute("");
      // Getting a reference to listview of main.xml layout file
      ListView listView = (ListView) findViewById(R.id.listview);
      // Setting the adapter to the listView
      listView.setAdapter(adapter);
      listView.setOnScrollListener(this);
  </code></pre>