Skip to content Skip to sidebar Skip to footer

Android: How To Start New Activity For Onitemclick Of List View That Uses Content Provider

By using the content provider I have inflated SMS in Inbox List View of my application. Now On item Click I want to show SMS text in another activity. I've implemented custom list

Solution 1:

list.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1,int pos, long arg3) {
        Intent i= new Intent(currentClass.this,secondActivity.class);
        i.putExtra("string",Yourlist.get(pos).sms);
        startActivity(i);
        finish();                       
    }
});

& on Another Activity You can receive through this:-

String msg=getIntent().getExtras().getString("string");

Solution 2:

lv.setOnItemClickListener(new OnItemClickListener() { 
public void onItemClick(AdapterView<?> parent, View view, int position, long id)  {   
switch(position)
{ case 0:
Intent firstIntent = new Intent(AndroidListViewActivity.this, SingleListItem.class);
startActivity(firstIntent);
break;
case 1:
Intent secondintent = new Intent(AndroidListViewActivity.this,jokes.class);               
startActivity(secondintent);
break; 

Post a Comment for "Android: How To Start New Activity For Onitemclick Of List View That Uses Content Provider"