Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes you will get <code>NullPointerException</code> because you are trying to access view which doesn't exists.</p> <p><strong>View doesn't exists? Why?</strong></p> <p>why because ListView recycle the views for the performance reasons. So it will allocate memory for the visible items in the list. i.e for example if you list has 100 items and you can see 10 items at a time, then listview will allocate memory for 10 views only, Remain views will be allocated when they are visible i.e when you scroll listview to identify items.</p> <p><strong>What you need to do?</strong></p> <p>Keep track of each item and its visibility in ArrayList and then set visibility of selected item to VISIBLE and rest to gone</p> <p>Sorry I can't code for you, but I'll provide alternate simple solution for you </p> <p>Try this simple way</p> <p>Example:</p> <p>Take a View like this in your Activity</p> <pre><code>View v; </code></pre> <p>And initialize it in <code>onCreate</code></p> <pre><code>v=new View(); </code></pre> <p>and in your listview onItemClick</p> <pre><code>lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View view, int position, long arg3) { v.setVisibility(View.GONE); v=view; view.setVisibility(View.VISIBLE); } }); </code></pre> <p><strong>Edit:</strong></p> <p>Take a Variable in your Adapter like this</p> <pre><code> int visibility=View.VISIBLE; </code></pre> <p>And </p> <p>set the visibility of items in your to </p> <pre><code> view.setVisibility(visibility); </code></pre> <p>And then in the <code>onItemClick</code> do like this</p> <p>you can access your visibility field in Activity with Adapter instance so</p> <pre><code>adapter.visibility=View.GONE; adapter.notifyDataSetChanged(); view.setVisibility(View.VISIBLE); </code></pre> <p>// second parameter in onItemClick</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. 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