In my FormActivity, there are two EditText's:

EditText editname = (EditText) findViewById(R.id.idname);
EditText editage  = (EditText) findViewById(R.id.idage);

then when user clicks:

String name = editname.getText().toString();
int age = parseInt(editage.getText().toString());

now my purpose is...

next time i visit the page(FormActivity), the last value of the editname and edit age is still there

thanks :)

有帮助吗?

解决方案

Are you trying to prepopulate those fields? If so, you can store them in the Bundle for your Activity and then restore them in the onResume() method. You can also store them on your device's flash memory, since your application is allocated some memory for storing configuration, and you could read them back out of local storage when your application starts

其他提示

TextView nameField = (TextView) this.findViewById(R.id.name);

This is assuming that you already loaded the layout using setContentView(R.layout.editinfo);

Use TextView.setText(Activity.getString(R.id.name)); (while Activity is your main activity)

edit: probably misundersood the question. use this if the string you want is in the xml. if you want to reference a TextView that is in the xml, use findViewById.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top