Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is quiet old UX problem - list view inside list view. It is not allowed in Android, but you can try some alternatives - <strong>one list view with different type of items</strong>. </p> <p>Android list view &amp; adapter support ViewType elements, so you can easily implemented it. For example,</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView) findViewById(R.id.list1); listView.setAdapter(new MyCustomAdapter(this)); } private class MyCustomAdapter extends ArrayAdapter&lt;Object&gt; { public MyCustomAdapter(Context context) { super(context, 0); } @Override public int getViewTypeCount() { return 2; //any number what you need. } @Override public int getItemViewType(int position) { //view type is managed as zero-based index. if(position &gt; 5) return 0; else return 1; } @Override public View getView(int position, View convertView, ViewGroup parent) { if( convertView == null ){ // View Recycling is managed separately based on its view type, // so you don't need to worry about view corruptions. LayoutInflater inflater = getLayoutInflater(); int type = getItemViewType(position); switch (type){ case 0: convertView = inflater.inflate(R.layout.item_type_0); case 1: convertView = inflater.inflate(R.layout.item_type_1); } } return convertView; } }//end of inner class }//end of class </code></pre> <p>You can use multiple view type in order to implement some special dividers or section bars, too. </p>
 

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