How can i open new window (TextView) from ListView by setOnItemClickListener?
I have tried it but it’s failed.I have two Xml files (i don’t know if i can have 2) and in second Xml file is that TextView. I am trying if i click on any item in ListView it will open new window with TextView.
There is my attempt:
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position,
long id) {
TextView message = (TextView)findViewById(R.id.message);
Uri uriSMSURIs = Uri.parse("content://sms/inbox");
Cursor c = getContentResolver().query(uriSMSURIs, null, null, null, null);
String bodys = c.getString(c.getColumnIndexOrThrow("body"));
setContentView(R.layout.text); ----> this is name of second Xml file "Text.xml"
message.setText(bodys);
}
});
If you want a new window in terms of an AlertDialog, then you should create one by reading this example: creating AlertDialogs
otherwise if you want to create a new Activity then i would do the following:
With this now you can define a new Activity class called TextMessage, which should look something like this:
This should do the trick for you.
p.s. be sure to declare the TextMessage class in the AndroidManifest.xml file