Create a class that inherits from AppCompatActivity

0

I do not know if this will be possible, I have a main class that has all the views and I want to create another one that inherits these views.

public class Tablero extends AppCompatActivity {

private FrameLayout main;
private Bitmap img;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);
    main = findViewById(R.id.idVista);
    img = BitmapFactory.decodeResource(getResources(), R.drawable.tile_borderland);
}

public void creaTablero (){
    ImageView tile = new ImageView(this); //Aqui lanza una excepción
    tile.setImageBitmap(img);
    main.addView(tile);
}
   }

However in the instruction

 ImageView tile = new 
 ImageView(this); 

throws an exception

  

android.content.Context.getResources () 'on a null object reference

I do not understand why I'm creating a new instance of ImageView.

    
asked by M.J.D 01.05.2018 в 10:47
source

0 answers