Reputation: 44
I have this following code:
ListView s1 = (ListView) findViewById(R.id.lista_contas);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_list_item_1, COUNTRIES);
s1.setAdapter(adapter);
This code shows my array of Countries, But what I am trying to do is when the user Touch and press down a country then I start a new Activity.
The process to start a new activity is ok for me, but my problem is the touch and press down.
Please help me regarding this.
Upvotes: 2
Views: 364
Reputation: 30980
Use the ListView
's setOnItemClickListener
to do what you need to when clicked:
s1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id){
// Start your Activity according to the item just clicked.
Log.d(TAG, "Item " +position+ " was clicked");
}
};)
Upvotes: 3