Android : How to show the value of a string in edittext

on Saturday, August 2, 2014


There are two activities in my project. I have the passed value to second activity from first. I want the passed value should appear in edittext. But when i run the following code it gives me both the edittext as blank.



//on mainactivity


Button b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i = new Intent(MainActivity.this,second.class);
i.putExtra("title", t);
i.putExtra("descrip", s);
startActivity(i);
MainActivity.this.finish();
}
});

//on second



et1 = (EditText) findViewById(R.id.fulltext);
et2 = (EditText) findViewById(R.id.editText2);
title = getIntent().getExtras().getString(title);
descp = getIntent().getExtras().getString(descp);
et2.setText(title, TextView.BufferType.EDITABLE);
et1.setText(descp, TextView.BufferType.EDITABLE);


Suggest a fix. Thanks in advance.


0 comments:

Post a Comment