问题描述
- 从另外的 activity 中调用按钮
- 如何从另外一个 activity 中编辑一个按钮?
它返回的是:java.lang.IllegalStateException: Could not execute method of the activityCaused by: java.lang.NullPointerException
但是我想在
Button getButton = (Button)findViewById(R.id.buttonGet);
获取getButton.setEnabled(false);
。
如何实现?
解决方案
确保在按钮获取一个引用时,要调用 setContentView:
在Button getButton = (Button)findViewById(R.id.buttonGet);
代码之前设置:
setContentView(R.layout.my_activity_layout);
解决方案二:
可以用传递handle,然后send message去更新ui
时间: 2024-08-03 18:51:08