开发者

How to change the value of a textView within a widget, from the value of a textEdit in another activity

If I have a widget that has a textView within it, and then a different class with an acti开发者_JS百科vity with a editText, is there a way to change the widget textView value, to the same value of the editText?


I guess you are using an Intent to switch between your activities.

You could use the method putExtra to send some data. In the activity where you have the textEdit :

Intent intent = new Intent(this, myClass.class);
intent.putExtra("key", "StringFromEditText");
startActivity(intent);

And get it in the activity where you have the textView :

Bundle extras = getIntent().getExtras();
String content = extras.getString("key");


Put the value of the EditText in a a database, file, or SharedPreferences in the activity that it's in, and read that back out in your widget.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜