<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_menu" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="example.igeniy.Menu"> <view class="example.igeniy.MainGamePanel" android:id="@+id/surface" android:layout_width="match_parent" android:layout_height="match_parent"> </view> <android.support.v7.widget.LinearLayoutCompat android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:layout_width="wrap_content" android:id="@+id/imageView1" android:layout_gravity="center_horizontal|top" android:layout_height="wrap_content" /> </android.support.v7.widget.LinearLayoutCompat> </FrameLayout> 

The error occurs when imageView1.setImageBitmap(bitmap); firstly, an error from the question header appears, and secondly, this line is shown as a reference to the zero imageView1.setImageBitmap(bitmap); object imageView1.setImageBitmap(bitmap);

 Объявлено `ImageView imageView1; Bitmap bitmap;` и `imageView1 = (ImageView) this.findViewById(R.id.imageView1);` `bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.kvadrat);` 

I was wrong with the choice of loyut? the class itself re-draws the game situation to my entire screen, and on top of the class I wanted to draw in imageview (transfer with the same FPS in imageview image can I use setImageBitmap often or should I use canvas?).

  • 1. Show how class example.igeniy.MainGamePanel - tse is defined
  • one
    2. Show where you assign imageView1 at least some value before accessing it? - tse
  • Thanks, your suggestive question helped to see the error. - Turalllb

1 answer 1

I am from the class of the inherited AppCompatActivity passing my markup to setContentView in which another class is declared. All imageview I have to declare in the class which displays my markup, and not in the class that itself is defined in the markup.