title: Problem when One listview uses different Layouts
body: <p>I'm experiencing a problem when trying to inflate different type of layouts based on a query on one <strong>list view</strong>. I am using this type so that the entire Activity can be wrapped into one listView and it looks like a scrollable webpage. I'm preferring AdapterView kind of layout because, I'll have to put some huge tables in between, which might get late to load if i inflate using some other kind of Layouts.</p>
  
  <p>I use something like this in the CursorAdapter class</p>
  
  <pre><code>public View newView(Context arg0, Cursor cur, ViewGroup parent) {
              final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
              View view = null;
              int viewIndex = cur.getInt(1);
              if (viewIndex == 0)
                 view = inflater.inflate(com.sayka.ordergadget.R.layout.takheader, parent, false);
              else if (viewIndex == 1)  {
                  view = inflater.inflate(com.sayka.ordergadget.R.layout.activity_order_items2, parent, false);
                  if (isNew) passFocus2Name((AutoCompleteTextView)view.findViewById(R.id.tak_itemName));
              }
              else if (viewIndex == 2)
                  view = inflater.inflate(com.sayka.ordergadget.R.layout.tak_footer, parent, false);
              return view;
          }
  </code></pre>
  
  <p>The problem is that AdapterView seems to inflate views just once. So when I query the cursor, <strong>a null pointer exception</strong> is caught on the BindView method. Cauz this time the adapter is trying to access Layout1 items from Layout2 because previously Layout2 was there in the place of Layout1. I tried to change the view itself if got an error like this</p>
  
  <pre><code>public void bindView(View view, Context cont, Cursor cur) {
  if (cur.getInt(1) == 2) {
                      TextView totItems_L, totItems_C, totItems, totQty_L, totQty_C, totQty, totAmt_L, totAmt_C, totAmt;
                      TextView testC;
  
                      try {
                          testC = (TextView)view.findViewById(com.sayka.ordergadget.R.id.totalItemsL);
                          testC.setText("Salim");
                      } catch (NullPointerException exp) {
                          ViewGroup parent = (ViewGroup)view.getParent();
                          final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
                          view = inflater.inflate(com.sayka.ordergadget.R.layout.tak_footer, parent, false);
                  }
  </code></pre>
  
  <p>here i'm trying to re-assign the view. But its not working. Any help would be appreciated. I'm new to android.</p>