Make sure you work with the same thing. If you change the background with another activity, first create a constructor, then use the "Change Object" button.
Activity obj= new activity(); obj.imgButton.setBackgroundResource(R.drawable.tab2_selected);
and also verify that the oncreate()
method has a void
return type if you only use findviewbyid
.
source share