I have the following code in my onCreate-method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView field1 = (ImageView) findViewById(R.id.field1);
field1.setBackgroundResource(R.drawable.field0);
How can I set the BackgroundResource in any other method like this:
public void setBackground() {
field1.setBackgroundResource(R.drawable.field2);
}
It says, that field1 cannot be resolved to a variable…
set field1 to global of the class, as follows: