I need to highlight a row in a ListView
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.
I already have the location by:
ListView.setSelection(position);
And now what I want is to select this specific row and to highlight it.
The code of the onCreate()
in the activity that contains the ListView
:
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<Coun> 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<?> 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();
}
});
}
}