我怎样才能做到这一点。我尝试了很多方法。但我不能。我唯一做的和工作的就是用消息填充列表。但是当我触摸它时,它什么也没做。如何使列表可点击并获取消息?
这是我的代码列表。它读取收件箱
ListView lViewSMS = (ListView) findViewById(R.id.listViewSMS);
if(fetchInbox()!=null)
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, fetchInbox());
lViewSMS.setAdapter(adapter);
}
}
public ArrayList<String> fetchInbox() {
ArrayList<String> sms = new ArrayList<String>();
Uri uriSms = Uri.parse("content://sms/inbox");
Cursor cursor = getContentResolver().query(uriSms, new String[]{"_id", "address", "date", "body"},null,null,null);
cursor.moveToFirst();
while (cursor.moveToNext())
{
String address = cursor.getString(1);
String body = cursor.getString(3);
System.out.println("======> Mobile number => "+address);
System.out.println("=====> SMS Text => "+body);
sms.add(address+"\n"+body);
}
return sms;
}
请帮助我在我的代码中添加什么。