title: button in listview adapter
body: <p>can any solve my problem..  At last after 2 days of struggle i got 70% of Output clearly.  Exp: i have listview which data is coming from server..Inside Listview there is some text,button and scroll index A,BC,D,E,F,G.<br>
  Problem: button is not working  means when i on click on it... if add below code.
  its looking some what below images: </p>
  
  <p>HERE I HAVE USED IN XML IN THIS WAY---> com.woozzu.android.widget.IndexableListView
  IN THIS CASE BUTTON ONCLICK IS NOT WORKING SCROLL VIEW A,B,C IS SHOWING IN correct manner and working fine..  </p>
  
  <p><img src="https://i.stack.imgur.com/SiAcg.png" alt="enter image description here"></p>
  
  <p><strong>Status 1:-</strong></p>
  
  <p>homempleb.xml</p>
  
  <pre><code>    &lt;LinearLayout
          android:id="@+id/scrollView1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_alignParentLeft="true"
          android:background="#335552"
          android:layout_below="@+id/relativeLayout4" &gt;                       
   &lt;com.woozzu.android.widget.IndexableListView          
              android:id="@+id/homelistView"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"               
              android:layout_weight="1.04"
              android:dividerHeight="0dip" /&gt;
  </code></pre>
  
  <p> </p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends Activity implements
      SearchView.OnQueryTextListener, SearchView.OnCloseListener {
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.homempleb);
      Log.i("scan", " txtScanResult ");
  
      ActionItem nextItem = new ActionItem();
      final QuickAction quickAction = new QuickAction(this,
              QuickAction.VERTICAL);
      quickAction.addActionItem(nextItem);
      quickAction.setOnDismissListener(new QuickAction.OnDismissListener() {
          @Override
          public void onDismiss() {
              Toast.makeText(getApplicationContext(), "Dismissed",
                      Toast.LENGTH_SHORT).show();
          }
      });
  
  
  
     // listView = (IndexableListView) findViewById(R.id.homelistView);
      listView = (ListView) findViewById(R.id.homelistView);
      listView.setTextFilterEnabled(true);
      listView.setFastScrollEnabled(true);
      listView.setFastScrollAlwaysVisible(true);
      objectAdapter = new EfficientAdapter(this);     
      listView.setAdapter(objectAdapter);
  </code></pre>
  
  <p>}</p>
  
  <p>EfficientAdapter.java</p>
  
  <pre><code>public class EfficientAdapter extends BaseAdapter implements SectionIndexer {
  
  private String mSections = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  ArrayList&lt;Patient&gt; patientListArray;
  
  private LayoutInflater mInflater;
  private Context context;
  protected ListView mListView;
  private int positions;
  ViewHolder holder;
  
  
  public EfficientAdapter(Context context) {
      mInflater = LayoutInflater.from(context);
      this.context = context;
  
      String patientListJson = CountriesList.jsonData;
      JSONObject jssson;
      try {
          jssson = new JSONObject(patientListJson);
          patientListJson = jssson.getString("PostPatientDetailResult");
      } catch (JSONException e) {
          e.printStackTrace();
      }
      Gson gson = new Gson();
      JsonParser parser = new JsonParser();
      JsonArray Jarray = parser.parse(patientListJson).getAsJsonArray();
      patientListArray = new ArrayList&lt;Patient&gt;();
      for (JsonElement obj : Jarray) {
          Patient patientList = gson.fromJson(obj, Patient.class);
          patientListArray.add(patientList);
          Log.i("patientList", patientListJson);
  
      }
  }
  
  /**
   * sorting the patientListArray data
   */
  public void sortMyData() {
      // sorting the patientListArray data
      Collections.sort(patientListArray, new Comparator&lt;Object&gt;() {
          @Override
          public int compare(Object o1, Object o2) {
              Patient p1 = (Patient) o1;
              Patient p2 = (Patient) o2;
              return p1.getName().compareToIgnoreCase(p2.getName());
          }
  
      });
  }
  
  public int getCount() {
  
      return patientListArray.size();
  }
  
  public Object getItem(int position) {
  
      return position;
  }
  
  public long getItemId(int position) {
      return position;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
  
      this.positions = position;
  
      if (convertView  == null) {                     
          convertView = mInflater.inflate(R.layout.homemplebrowview, parent,false);
          holder = new ViewHolder();
          holder.text1 = (TextView) convertView.findViewById(R.id.name);
          holder.text2 = (TextView) convertView.findViewById(R.id.mrn);
          holder.text3 = (TextView) convertView.findViewById(R.id.date);
          holder.text4 = (TextView) convertView.findViewById(R.id.age);
          holder.text5 = (TextView) convertView.findViewById(R.id.gender);
          holder.text6 = (TextView) convertView.findViewById(R.id.wardno);
          holder.text7 = (TextView) convertView.findViewById(R.id.roomno);
          holder.text8 = (TextView) convertView.findViewById(R.id.bedno);
  
  
          holder.btnList = (Button) convertView.findViewById(R.id.listbutton);
  
          convertView.setTag(holder);
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      holder.text1.setText(Util.formatN2H(patientListArray.get(position)
              .getName()));
      holder.text2.setText(patientListArray.get(position).getMrnNumber());
      holder.text3.setText(Util.formatN2H(patientListArray.get(position)
              .getRoom()));
      holder.text4.setText(Util.formatN2H(patientListArray.get(position)
              .getAge()));
      holder.text5.setText(Util.formatN2H(patientListArray.get(position)
              .getGender()));
      holder.text6.setText(Util.formatN2H(patientListArray.get(position)
              .getWard()));
      holder.text7.setText(Util.formatN2H(patientListArray.get(position)
              .getRoom()));
      holder.text8.setText(Util.formatN2H(patientListArray.get(position)
              .getBed()));
  
  
      //  holder.btnList.setOnClickListener(new OnClickListener(test));
  
      holder.btnList.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {                   
              Toast.makeText(context, "STAT", Toast.LENGTH_SHORT).show();
              Intent next = new Intent(context, Home.class);
              Log.i("next23", "next"+ next);
              context.startActivity(next);
          }
      });
  
      return convertView;
  }
  
  
  
        /*OnItemClickListener test = new OnItemClickListener() {
  onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id){
        ((TextView)view.findViewById(R.id.yourTextViewId)).getText();
  
    {
  //    Button btnList=(Button)v.findViewById(R.id.listbutton);
  
      btnList.setOnClickListener(new OnClickListener(){
      public void onClick(View v) {                   
          Toast.makeText(context, "STAT", Toast.LENGTH_SHORT).show();
          Intent next = new Intent(context, Home.class);
          Log.i("next23", "next"+ next);
          context.startActivity(next);
      }
  
  });
        }
  
           };
        */
  
  
  static class ViewHolder {
      public Button btnList;
      public TextView text8;
      public TextView text7;
      public TextView text6;
      public TextView text5;
      public TextView text4;
      public TextView text1;
      public TextView text2;
      public TextView text3;
  }
  
  @Override
  public void notifyDataSetChanged() {
      super.notifyDataSetChanged();
  }
  
  
  
         /*public void onItemClick(AdapterView&lt;?&gt; arg0, View v, final int position,
            long arg3)
        {
      holder.btnList=(Button)v.findViewById(R.id.listbutton);
  
      holder.btnList.setOnClickListener(new OnClickListener(){
      public void onClick(View v) {                   
          Toast.makeText(context, "STAT", Toast.LENGTH_SHORT).show();
          Intent next = new Intent(context, Home.class);
          Log.i("next23", "next"+ next);
          context.startActivity(next);
      }
  
  });
        }
          */
  
  
  
  public int getPositionForSection(int section) {
      // sorting the patientListArray data
      sortMyData();
      // If there is no item for current section, previous section will be
      // selected
      for (int i = section; i &gt;= 0; i--) {
          for (int j = 0; j &lt; getCount(); j++) {
              if (i == 0) {
                  // For numeric section
                  for (int k = 0; k &lt;= 9; k++) {
                      if (StringMatcher.match(
                              String.valueOf(patientListArray.get(j)
                                      .getName().charAt(0)),
                              String.valueOf(k)))
                          return j;
                  }
              } else {
                  if (StringMatcher.match(
                          String.valueOf(patientListArray.get(j).getName()
                                  .charAt(0)),
                          String.valueOf(mSections.charAt(i))))
                      return j;
              }
          }
      }
      return 0;
  }
  
  public int getSectionForPosition(int position) {
      return 0;
  }
  
  public Object[] getSections() {
      String[] sections = new String[mSections.length()];
      for (int i = 0; i &lt; mSections.length(); i++)
          sections[i] = String.valueOf(mSections.charAt(i));
      return sections;
  }
  
      }
  </code></pre>
  
  <p><strong>Status 2:-</strong> </p>
  
  <p>In this case Button on click is working fine  but scroll view A,B,C is also working fine but in side there will be no alphabetic A,B,C,D,E,F,G... 
  IF I ADD listview in homempleb.xml, THEN BOTH WILL WORK FINE BUT NO ALPHABETIC INDEX LIKE SHOWN IN IMAGES. I want both button and scroll index work like above images.. i am not good in this topics. plz help me
   IT SHOWS IN THIS WAY:  </p>
  
  <p><img src="https://i.stack.imgur.com/6V8r5.png" alt="enter image description here"></p>
  
  <p>homempleb.xml</p>
  
  <pre><code>&lt;LinearLayout
          android:id="@+id/scrollView1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_alignParentLeft="true"
          android:background="#335552"
          android:layout_below="@+id/relativeLayout4" &gt;                      
       &lt;ListView
              android:id="@+id/homelistView"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"               
              android:layout_weight="1.04"
              android:dividerHeight="0dip" /&gt;
  </code></pre>
  
  <p> </p>