Android : how to select inbox msg display on another activity of textview

on Thursday, September 18, 2014


I am new android developer.I selected msg from inbox display on textview of another activity. Three java file mainactivity.java-select msg display on TextView 7



Intent intent = getIntent();
String msg = intent.getStringExtra("Msg_Detail");
//String msg = intent.getExtras().getString("Msg_Detail");
TextView7 = (TextView) findViewById(R.id.TextView7);
TextView7.setText(msg);
**MessageBox.java**
lvMsg = (ListView) findViewById(R.id.lvMsg);
Uri inboxURI = Uri.parse("content://sms/inbox");

// List required columns
String[] reqCols = new String[] { "_id", "address", "body" };

// Get Content Resolver object, which will deal with Content
// Provider
ContentResolver cr = getContentResolver();

// Fetch Inbox SMS Message from Built-in Content Provider
Cursor c = cr.query(inboxURI, reqCols, null, null, null);

// Attached Cursor with adapter and display in listview
adapter = new SimpleCursorAdapter(this, R.layout.row, c,
new String[] { "body", "address" }, new int[] {
R.id.lblMsg, R.id.lblNumber });
lvMsg.setAdapter(adapter);
lvMsg.setOnItemClickListener(new OnItemClickListener() {

private Intent intent;

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String msg=(String) lvMsg.getSelectedItem();
//String msg =(String)(lvMsg.getItemAtPosition(position));
// String msg=((TextView)view.findViewById(R.id.lvMsg)).getText().toString();
//list item = (list) adapter.getItem(position);

Intent in = new Intent(getApplicationContext(),MainActivity.class);

//String msg = null;
in.putExtra("Msg_Detail", msg);
startActivity(in);

}
});


list.java-(contain two textview(lblno,lblMsg)Inbox message display thar format ) setContentView(R.layout.row);



txt = (TextView) findViewById(R.id.lblMsg);
txt2= (TextView) findViewById(R.id.lblNumber);


I try comment coding also but when I select inbox msg the page go to Messagebox.java to mainactivity but not display msg. please check my Messagebox coding


0 comments:

Post a Comment