Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There will always be as many Views in the List as can be seen by the user. When the user scrolls, the views that go out of view get reused to show the new list data the user scrolled to. You need to reset the list item's state when they are redrawn.</p> <p>Add a boolean variable 'expanded' to the object that stores the list data. (The objects you add to the ArrayAdapter). Set expanded = true when the user expands the LinearLayout in the listItem.</p> <pre><code>public class MyListItem { public boolean expanded = false; // data you are trying to display to the user goes here // ... } </code></pre> <p>Then do this in the list adapter's getView method</p> <pre><code>public class MyListAdapter extends ArrayAdapter&lt;MyListItem&gt; { public MyListAdapter (Context context, ArrayList&lt;AudioPlaylist&gt; objects) { super(context, R.layout.list_item, objects); } @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout rowLayout; MyListItem item = this.getItem(position); if (convertView == null) { rowLayout = (LinearLayout) LayoutInflater.from(this.getContext()).inflate(R.layout.list_item, parent, false); } else { rowLayout = (LinearLayout) convertView; } //set the textviews, etc that you need to display the data with //... LinearLayout expanded = rowLayout.findViewById(R.id.expanded_area_id); if (item.expanded) { //show the expanded area expanded.setVisibility(View.VISIBLE); } else { //hide the area expanded.setVisibility(View.GONE); } return rowLayout; } } </code></pre> <p>Make sure your list_item.xml has a LinearLayout wrapping the whole thing otherwise you will get an cast exception.</p> <p>Hope that helps...</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. 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