Grant
Grant

Reputation: 4553

Switch between Android activities when listview item clicked

I searched for hours to find good tutorial about switching between Android activities when a list view item clicked. All tutorials describe about calling different activities for different list view item clicked, but I want to run same activity without considering what item is clicked Here is the code I have used but this is not work.

   list.setOnItemClickListener(new OnItemClickListener() {

     public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt,
                        long paramLong) {
                    Intent newActivity = new Intent(getApplicationContext(), OrderDetails.class);     
                    startActivity(newActivity);
                }
                });

Activity called in Manifest.xml

</activity>
    <activity android:name=".OrderetDetails"></activity>
</application>

How can I do that if it is possible ?

Thanks!

Upvotes: 0

Views: 593

Answers (1)

Christian
Christian

Reputation: 1840

You need to use onListItemClick instead of onItemClick.

Something like this:

public void onListItemClick( final ListView l, final View v, final int position, final long id ) {
    Intent newActivity = new Intent(getApplicationContext(), OrderDetails.class);     
    startActivity(newActivity);
}

Upvotes: 1

Related Questions