my class extends Activity, not ListActivity. i have this code on create method but i select an item from the list, the background of it dont stay orange. I have to move the arrows in the emulator for down to navigate on the listview.
When i click on the button center on the emulator, the log dont show the message.
I tired of try many thinks and i still without get the action when i select one item from the list.
Any sugestions?? thanks a lot
final List<Profile> profilesList = getProfilesList();
ProfileArrayAdapter3 adapter = new ProfileArrayAdapter3(
getApplicationContext(), R.layout.profiles_item, profilesList);
listViewProfiles = (ListView) this.findViewById(R.id.profilesList);
listViewProfiles.setAdapter(adapter);
listViewProfiles.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Toast.makeText(getApplicationContext(), profilesList.get(position).getCardNumber(), Toast.LENGTH_SHORT).show();
Log.d("cardNumber",profilesList.get(position).getCardNumber());
}});
Personnaly, I prefer to use click listeners on my view than using a itemclicklistener on the list itself. Click listeners on views can be shared, and you will get the source of the event using the parameter of onClick.
Here is an example :
Regards,
Stéphane