Rootstonian
Newbie
I have an app that has an EditText box and an "Ok" button.
When they click Ok, the text shows up, but on a new page. I wanted to see it below the ok button. Here is the code:
When they click Ok, the text shows up, but on a new page. I wanted to see it below the ok button. Here is the code:
Code:
public class App2 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText textname = (EditText) findViewById(R.id.EditText01);
Button btn1 = (Button)findViewById(R.id.Button01);
// Get Text on Button Press
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
String str = textname.getText().toString();
TextView tv = new TextView(getApplicationContext());
tv.setText(str);
setContentView(tv);
}
});
}
}