Android的:如何启动的列表视图OnItemClick使用内容提供商的新活动 [英] Android: How to start new activity for OnItemClick of List View that uses content provider
问题描述
使用我在我的应用程序的收件箱列表视图充气短信内容提供商。现在,在项目点击我要显示在另一个活动的短信。我实现了自定义列表视图。现在,我没有得到如何挑选每一个列表项,并显示在点击新的活动。在一个堆栈流动的回答有人提出这样的:
@覆盖
保护无效onListItemClick(ListView中升,视图V,INT位置,长的id){
乌里mailUri = ContentUris.withAppendedId(getIntent()的getData(),身份证);
startActivity(新意图(Intent.ACTION_VIEW,mailUri));
}
如果这个code正确,那么我是如何将配置下一个活动在此ACTION_VIEW行动?
list.setOnItemClickListener(新OnItemClickListener(){
@覆盖
公共无效onItemClick(适配器视图<>为arg0,ARG1观,诠释POS,长ARG3){
意图I =新意图(currentClass.this,secondActivity.class);
i.putExtra(字符串,Yourlist.get(POS)的.sms);
startActivity(ⅰ);
完();
}
});
&安培;在另一项活动就可以透过这样的: -
弦乐味精= getIntent()getExtras()的getString(字符串)。
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 view. Now I am not getting how to pick each single list item and show in new activity on click. In a Stack flow answer somebody suggested this:
@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));
}
If this code is correct then how I will configure next activity to act upon this ACTION_VIEW?
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");
这篇关于Android的:如何启动的列表视图OnItemClick使用内容提供商的新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!