Android 安卓短信意图问题
我正试图打开系统短信应用程序与短信正文是从一个数据库 我正在使用Android 安卓短信意图问题,android,sqlite,sms,android-listview,android-cursor,Android,Sqlite,Sms,Android Listview,Android Cursor,我正试图打开系统短信应用程序与短信正文是从一个数据库 我正在使用Cursor从SQLite数据库检索标题和消息。我有一个将被单击的smsButton。单击时,它将创建sms意图 我的问题是消息的主体。我希望主体是从数据库检索的msg_内容。我试图引用它,但我相信我失败了 这是我最后一次尝试,尝试创建一个文本视图,该视图将采用msg_内容布局的id: //First: DataBase Retrieving : //fetch a msg from table `t` with id `id` C
Cursor
从SQLite
数据库检索标题和消息。我有一个将被单击的smsButton
。单击时,它将创建sms意图
我的问题是消息的主体。我希望主体是从数据库检索的msg_内容。我试图引用它,但我相信我失败了
这是我最后一次尝试,尝试创建一个文本视图,该视图将采用msg_内容布局的id:
//First: DataBase Retrieving :
//fetch a msg from table `t` with id `id`
Cursor cursor = myDbHelper.fetchMessage(t, id);
String[] columns = {cursor.getColumnName(1), cursor.getColumnName(2)};
int[] columnsLayouts = {R.id.title, R.id.msg_content}; //the columns styles
ca = new SimpleCursorAdapter(this.getBaseContext(), R.layout.msg_items_layout, cursor,columns , columnsLayouts);
lv = (ListView) findViewById(android.R.id.list);
lv.setAdapter(ca);
//Here is MY PROBLEM :
TextView msgText = (TextView) findViewById(R.id.msg_content); //same Id as the msg_content column above
smsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String uri= "smsto:";
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
intent.putExtra("sms_body", msgText.getText());
intent.putExtra("compose_mode", true);
startActivity(intent);
}
});
有没有方法引用内容字符串?您正在对活动调用
findViewById()
。。。从数据库中获取数据
您应该使用光标
获取您的信息
由于您没有费心提供实际的源代码(只有几个不连续的代码片段,AFAICT),因此很难给您提供具体的建议。随机尝试一个答案,我会删除smsButton
,而是监听ListView
项目的点击(例如,onListItemClick()
,如果您正在实现ListActivity
),然后使用提供的位置移动到光标的右侧位置,并读取数据