Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar situation but fixed that easily. Try this:</p> <ol> <li><p>Extend ListActivity and set your custom list adapter</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //if you need title to be hidden setContentView(R.layout.activity_add_to_cart_select_service_plan); setListAdapter(adapter); } </code></pre></li> <li><p>Create a field to store selected index position in adapter</p> <pre><code>int selectedIndex = -1; </code></pre></li> <li><p>Provide an interface to it</p> <pre><code>public void setSelectedIndex(int index){ selectedIndex = index; } </code></pre></li> <li><p>Set the checked state to true or false based on the selected index inside getView()</p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { RadioButton rbSelect = (RadioButton) convertView .findViewById(R.id.radio1); if(selectedIndex == position){ rbSelect.setChecked(true); } else{ rbSelect.setChecked(false); } } </code></pre></li> <li><p>Set radio button focusable and clickable attribs to 'false'</p> <pre><code> &lt;RadioButton android:id="@+id/radio1" android:checked="false" android:focusable="false" android:clickable="false" /&gt; </code></pre></li> <li><p>Set listview descendantFocusability attrib to 'beforeDescendants'</p> <pre><code>&lt;ListView android:id="@android:id/list" android:choiceMode="singleChoice" android:descendantFocusability="beforeDescendants" /&gt; </code></pre></li> <li><p>Override onListItemClick</p> <pre><code>@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); adapter.setSelectedIndex(position); adapter.notifyDataSetChanged(); } </code></pre></li> </ol> <p>That's it..run and check</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. 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