Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem with multiple item types in the list. In my case the list item was either a section (label) item or a common list item.</p> <p>To work with such types of lists, you should override <code>getViewTypeCount</code> and <code>getItemViewType</code> methods. Something like this:</p> <pre><code>private static final int ITEM_VIEW_TYPE_ITEM = 0; private static final int ITEM_VIEW_TYPE_SEPARATOR = 1; @Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { return this.getItem(position).isSection() ? ITEM_VIEW_TYPE_SEPARATOR : ITEM_VIEW_TYPE_ITEM; } @Override public View getView(int position, View convertView, ViewGroup parent) { final Item item = this.getItem(position); if (convertView == null) { convertView = mInflater.inflate(item.isSection() ? R.view1 : R.view2, null); } if(item.isSection()){ //... } else{ //... } return convertView; } </code></pre> <p>Then the convertView parameter will always be correct and contain that type which you need.</p> <p>And another thing: you explicitly added the <code>public Param[] params</code> field when you already have it in the base class <code>ArrayAdapter&lt;Param&gt;</code>.</p> <p>I would recommend to inherit from the <code>BaseAdapter</code> class.</p> <p><strong>Edit:</strong> Here is the code which you can try to use in order to make your <code>Spinner</code> work:</p> <pre><code>sp.setTag(p); sp.setOnItemSelectedListener(new OnItemSelectedListener(){ public void onItemSelected(AdapterView&lt;?&gt; parent, View convertView, int pos, long id) { Param currentItem = (Param)parent.getTag(); currentItem.setDefData(currentItem.getData().get(pos)); currentItem.setChanged(true); } //... </code></pre> <p>Try to use the combination of the <code>getTag</code> and <code>setTag</code> methods. I remember that I had similar problems with event handlers and final variables, but I completely forgot the cause of them, so I can't explain exactly why this happens.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload