Hi I am trying to create a comment box and what I can't create is to display the message from the comment box on the actual screen not toasting it but storing it somehow. The idea is that I want to create a comment box and store+display the comments on the screen. What I have now is that I can just toast the comment.Is there any possible way of displaying the comments, and even if I re run the app the comment would still be there ? here is my code.
public class commentbox extends Activity {
private EditText edittext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.comment);
addKeyListener();
}
public void addKeyListener() {
// get edittext component
edittext = (EditText) findViewById(R.id.editText);
// add a keylistener to keep track user input
edittext.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// if keydown and "enter" is pressed
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// display a floating message
Toast.makeText(commentbox.this,
edittext.getText(), Toast.LENGTH_LONG).show();
return true;
} else if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_9)) {
// display a floating message
Toast.makeText(commentbox.this,
"Number 9 is pressed!", Toast.LENGTH_LONG).show();
return true;
}
return false;
}
});
}
}