Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to highlight row in ListView in Android?
    primarykey
    data
    text
    <p>I need to highlight a row in a <code>ListView</code> that was selected (to show the user what he chose), so, it's not the one that is going to be chosen, it's the one he chose before.</p> <p>I already have the location by:</p> <pre><code>ListView.setSelection(position); </code></pre> <p>And now what I want is to select this specific row and to highlight it.</p> <p>The code of the <code>onCreate()</code> in the activity that contains the <code>ListView</code>:</p> <pre><code>public class CountryView extends Activity { protected static final String LOG_TAG = null; /** Called when the activity is first created. */ String[] lv_arr = {}; ListAdapter adapter; TextView t; private ListView lvUsers; private ArrayList&lt;Coun&gt; mListUsers; String responce=null; public int d; int selectedListItem = -1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.country); Intent data =getIntent(); mListUsers = getCoun(); lvUsers = (ListView) findViewById(R.id.counlistView); lvUsers.setAdapter(new ListAdapter(this, R.id.counlistView, mListUsers)); selectedListItem=data.getExtras().getInt("PositionInList"); lvUsers.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lvUsers.setOnItemClickListener(new OnItemClickListener() { int positionItem; public void onItemClick(AdapterView&lt;?&gt; parent, View view,int position, long id) { Intent pongIntent = new Intent(getApplicationContext(),Trav.class); int counId=mListUsers.get(position).id; pongIntent.putExtra("response",mListUsers.get(position).p); pongIntent.putExtra("responseCounID",counId); //Put the position of the choose list inside extra positionItem=position; pongIntent.putExtra("PositionInListSet",positionItem); setResult(Activity.RESULT_OK,pongIntent); Log.i("CounID *******************************"," "+counId); finish(); } }); } } </code></pre>
    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.
 

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