Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The only way I see to achieve this would be to indeed create a custom adapter class. I'm using this to create a file browsers, with different actions based on wether the item selected is a file or a folder. </p> <p>Basically, You need to create a custom adapter extending ArrayAdapter (you can use another base class if all your items inherit from the same class). Here's a sample code :</p> <pre><code>public class MyCustomAdapter extends ArrayAdapter&lt;Object&gt; { public MyCustomAdapter(Context context, int textViewResourceId, ArrayList&lt;Object&gt; objects) { super(context, textViewResourceId, objects); mList = objects; } public View getView(int position, View convertView, ViewGroup parent) { Object obj = mList.get(position); View v = convertView; LayoutInflater vi = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (obj.getClass().isAssignableFrom(MyClass1.class)){ v = vi.inflate(R.layout.myclass1_item_layout, null); setupViewClass1(obj,v); } else if (obj.getClass().isAssignableFrom(MyClass2.class)){ v = vi.inflate(R.layout.myclass2_item_layout, null); setupViewClass2(obj,v); } return v; } private void setupViewClass1 (Object obj, View v){ // setup the content of your view (labels, images, ...) } private void setupViewClass2 (Object obj, View v){ // setup the content of your view (labels, images, ...) } private ArrayList&lt;Object&gt; mList; } </code></pre> <p>Then you need to add an OnItemClickListener as well as an OnCreateContextMenuListener to handle the click and longpress event on your list, again making a filter on the class of your object. </p>
    singulars
    1. This table or related slice is empty.
    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.
    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