【发布时间】:2017-12-31 00:23:32
【问题描述】:
各位开发者,
我想通过单击按钮将 textView 的文本更改为按钮的文本。我已经尝试了几个代码,但没有任何效果,我的应用程序正在停止而没有错误。
这是我的代码:
TextView textView1 = (TextView) findViewById(R.id.textView1);
Button button1 = (Button) findViewById(R.id.button1);
textView1.setText(button1.getText());
已经感谢您的帮助:)
编辑:它抛出 IllegalStateException、InvocationTargetException 和 NullPointerExcpetion。
【问题讨论】:
-
你应该提供一个最小的、完整的、可验证的例子stackoverflow.com/help/mcve