Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView selected item stay highlighted
    primarykey
    data
    text
    <p>I have an <code>XML</code> with two <code>ListView</code>, one with a list of clients filled by a select query (<code>lv_cli</code>) and the other with the details of the client selected (<code>lv_cli_det</code>). I would like to keep the client selected in the <code>lv_cli</code> while the <code>lv_cli_det</code> show the details.</p> <p>XML:</p> <pre><code>&lt;ListView android:id="@+id/cli_lista" android:layout_width="512dp" android:layout_height="wrap_content" android:fadeScrollbars="false" &gt; &lt;/ListView&gt; &lt;ListView android:id="@+id/cli_lista_det" android:layout_width="512dp" android:layout_height="wrap_content" android:layout_toRightOf="@+id/cli_lista" android:fadeScrollbars="false" &gt; &lt;/ListView&gt; </code></pre> <p>Java:</p> <pre><code>Cursor cursor = db.rawQuery("Select NrCl||';'||Nome From Clientes", null); final ListView t = (ListView)findViewById(R.id.cli_lista); ArrayAdapter&lt;String&gt; myarrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_expandable_list_item_1, listItems); t.setAdapter(myarrayAdapter); final ListView td = (ListView)findViewById(R.id.cli_lista_detalhe); final ArrayAdapter&lt;String&gt; myarrayAdapter2 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_expandable_list_item_1, listItems2); t.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String item = ((TextView)view).getText().toString(); String[] strArray = item.split("\\;"); cli.load(strArray[0].toString()); td.setAdapter(myarrayAdapter2); listItems2.clear(); listItems2.add("Nome: " + cli.getNome()); listItems2.add("Morada: " + cli.getMorada()); listItems2.add("Localidade: " + cli.getLoca()); listItems2.add("Código Postal: " + cli.getCp()); listItems2.add("Pais: " + cli.getPais()); listItems2.add("Nif: " + cli.getNif()); listItems2.add("Tel: " + cli.getTel()); listItems2.add("Tlm: " + cli.getTlm()); listItems2.add("Tipo Preço: " + cli.getTipoPvn()); listItems2.add("Cond. Pagamento: " + cli.getCpg()); listItems2.add("Obs: " + cli.getObs()); td.setAdapter(myarrayAdapter2); myarrayAdapter2.notifyDataSetChanged(); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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