title: Display multiple views with merge adpter in android list view
body: <p>I have a problem where I need to display two text views in one list item.</p>
  
  <p>One view shows the item, clicking on which opens the item.
  The other view is a plus icon, expanding the list with its children.</p>
  
  <p>I scratched my head a lot, but couldn't find a way to detect which view was selected in the list view.</p>
  
  <p>Somehow, I came up with <code>MergeAdapter</code>, I followed it and added two adapters to it.
  The first adapter shows actual titles, while the other just shows a plus icon.</p>
  
  <p>But the list only shows the first text view, and not the plus icon.</p>
  
  <p>What else do I need in <code>MergeAdapter</code> to show both the views?</p>
  
  <p>Displays the title, clicking on this should open the selected title page</p>
  
  <p>`</p>
  
  <pre><code>public class TitleAdapter extends BaseAdapter {
  
      private List&lt;Title&gt; navItems;
      private LayoutInflater layoutInflater;
  
      public TitleAdapter(Context context, List&lt;Title&gt; navItems) {
          this.layoutInflater = LayoutInflater.from(context);
          this.navItems = navItems;       
      }
      @Override
      public int getCount() {
          return navItems.size();
      }
  
      @Override
      public Object getItem(int position) {
          return navItems.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return navItems.get(position).getTitleID();
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = null;
  
          TextView textView = null;
  
          if(convertView == null) {
              view = layoutInflater.inflate(R.layout.drawer_list_item, parent, false);
  
          } else {
              view = convertView;
          }
  
          textView = (TextView) view.findViewById(R.id.textView);
  
          Title item = (Title)getItem(position);
  
          textView.setText(item.getTitle());
  
          return view;
      }
  }
  </code></pre>
  
  <p>`</p>
  
  <p>Displays the + icon, clicking on it should add new entries in the list, i.e., children of the selected title</p>
  
  <p>`</p>
  
  <pre><code>public class ExpandAdapter extends BaseAdapter {
  
      private int items;
      private LayoutInflater layoutInflater;
  
      public ExpandAdapter(Context context, int items) {
          this.layoutInflater = LayoutInflater.from(context);
          this.items = items;
  
      }
      @Override
      public int getCount() {
          return items;
      }
  
      @Override
      public Object getItem(int position) {
          return "+";
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = null;
  
          if(convertView == null) {
              view = layoutInflater.inflate(R.layout.drawer_list_item2, parent, false);
  
          } else {
              view = convertView;
          }
  
          return view;
      }
  }
  </code></pre>
  
  <p>`</p>
  
  <p>drawer_list_item:
  `</p>
  
  
  
  <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/textView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textColor="@color/dark_grey"
            android:textSize="20sp"
            android:textStyle="normal"
            style="?android:attr/listSeparatorTextViewStyle"
            android:text="Hi" /&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>drawer_list_item2:</p>
  
  <p>`</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/expandBtn"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textColor="@color/dark_grey"
            android:textSize="20sp"
            android:textStyle="normal"
            style="?android:attr/listSeparatorTextViewStyle"
            android:text="+" /&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>But i can't see the plus icon!</p>
  
  <p>I added it in <code>MergeAdapter</code> like this:</p>
  
  <p>`</p>
  
  <pre><code>MergeAdapter m = new MergeAdapter();        
  TitleAdapter t = new TitleAdapter(this, navItems, hasChild);
  ExpandAdapter e = new ExpandAdapter(this, navItems.size());
  m.addAdapter(t);
  m.addAdapter(e);
  </code></pre>
  
  <p>`</p>