1

コンテンツプロバイダーを使用することにより、アプリケーションの受信トレイリストビューでSMSを膨らませました。今すぐアイテムをクリックします別のアクティビティでSMSテキストを表示します。カスタムリストビューを実装しました。現在、各リストアイテムを選択して、クリックすると新しいアクティビティに表示する方法がわかりません。スタックフローの回答で、誰かがこれを提案しました:

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri mailUri = ContentUris.withAppendedId(getIntent().getData(), id);
    startActivity(new Intent(Intent.ACTION_VIEW, mailUri));
}

このコードが正しい場合、このACTION_VIEWに基づいて動作するように次のアクティビティをどのように構成しますか?

4

2 に答える 2

3
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();                       
    }
});

&別のアクティビティであなたはこれを通して受け取ることができます:-

String msg=getIntent().getExtras().getString("string");
于 2012-10-29T10:50:14.463 に答える
0
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; 
于 2014-04-30T12:00:26.087 に答える