I write an travel APP.There are 20 QR Code in every spot.
When tourist use QR Code scanner scan the QR Code,the ImageButton's image have to change into another image.
The problem on this line : spot1.setImageResource(R.drawable.hotspot1);
If I delete this line, there is no problem.
I don't know how to fix it.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (0 == requestCode && null != data && data.getExtras() != null) {
String result = data.getExtras().getString("la.droid.qr.result");
int spotnum=Integer.valueOf(result);
switch(spotnum){
case 1:
ImageButton spot1=(ImageButton)findViewById(R.id.imageButton1);
spot1.setImageResource(R.drawable.hotspot1);
setContentView(R.layout.hotspot1);
break;
case 2:
setContentView(R.layout.hotspot2);
break;
}
}
}
Here is my Logcat:https://i.sstatic.net/6y2UQ.png