想从其他活动改变TextView的文本? [英] Want to change text of TextView from other activity?

查看:105
本文介绍了想从其他活动改变TextView的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前设计的电子书阅读器应用为我的项目,我有改变文本的问题在的TextView 其他的活动。

i am currently designing a ebook reader app as my project, i am having a problem in changing text of the textview from other activity.

我的项目内容,

活动1 包含两个按钮,当按钮1 点击一些文本应该会出现,当按钮2 点击其他一些文本 sholud出现在 TextView1 这是在活性2

Activity 1 contains two buttons and when button1 is clicked "Some Text" Should appear and when button2 is clicked "Some Other Text" sholud appear in a TextView1 which is in Activity2.

我的意思是,案文应只出现在TextView1。没有其他的TextView。没关系。

i mean the text should appear in TextView1 only. there is no other textview. okay.

请解决我的问题用一个简单的code的例子。

please solve my problem with a simple code example.

对不起,在问题中的任何错误,因为这是我第一次真正让互联网上的问题的尝试。

Sorry for any mistakes in the question as it is my first attempt to really ask a question on internet.

感谢您

推荐答案

据我知道你不能访问UI组件of2nd活动,而在第一项活动之中。所以最好的办法是通过意图的putExtra方法的值,然后将其通过获取其在第二届活动的OnCreate到TextView的。下面这里是链接,显示了该方法

As far as i know you cannot access the UI component of2nd activity while being in first activity. so the best way is to pass the value through putExtra method of intents and then set it to textview in the oncreate of 2nd activity by getting it. here below is link which shows this method

<一个href=\"http://mobileorchard.com/android-app-development-using-intents-to-pass-data-and-return-results-between-activities/\" rel=\"nofollow\">http://mobileorchard.com/android-app-development-using-intents-to-pass-data-and-return-results-between-activities/

这篇关于想从其他活动改变TextView的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆