0
我想在使用相机拍照后更改Button属性。java.lang.RuntimeException:将结果传递给活动失败{}:java.lang.NullPointerException
@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
文本按钮出这个方法。按钮=(按钮)findViewById(R.id.btnChange); –你是什么意思创建一个对象?那我怎么能改变按钮的属性呢?你能给我一些代码示例吗? – Naskov
Button button =(Button)findViewById(R.id.btnChange);在你的活动中去除这个。你可以在上面的方法中使用button.setText()。 –