【发布时间】:2012-11-29 10:08:39
【问题描述】:
我正在尝试在使用相机拍照后更改 Button 属性。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) return;
Bitmap bitmap = utilities.decodeFile(path, 300);
imgPicHolder.setImageBitmap(bitmap);
//The pic is changing on the previous Activity, this works fine
Button button = (Button)findViewById(R.id.btnChange);
button.setText("NewText");
//Here is the problem, when trying to change the button property from the previous activity before taking the picture..
}
【问题讨论】:
-
用这个方法创建按钮的obj。Button button = (Button)findViewById(R.id.btnChange);
-
创建对象是什么意思?之后我将如何更改按钮的属性?你能给我一些代码示例吗?
-
按钮按钮 = (Button)findViewById(R.id.btnChange);在你的活动中定义这个。您可以在上述方法中使用 button.setText()。
-
findViewById将在当前活动中查找视图,如果Button在以前的子活动中(现在已死),它显然不起作用。
标签: android android-intent camera