Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:21:19+00:00 2026-06-12T11:21:19+00:00

solved by Emil thx I have following in my main package com.example.surfacetest; import android.os.Bundle;

  • 0

solved by Emil thx
I have following in my main

package com.example.surfacetest;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.BitmapFactory;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        //this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,     WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        ImageView img = (ImageView) findViewById(R.drawable.hero_frame);
        img.setImageBitmap(BitmapFactory.decodeResource(this.getResources(),R.drawable.chen_gong));

    }

}
`

in the xml file I have

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_world"
    tools:context=".MainActivity" />
<ImageView
    android:id="@+id/hero1"
    android:maxWidth="100dp"
    android:maxHeight="100dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:layout_marginLeft="5.33dp"
    />
<ImageView
    android:id="@+id/hero2"
    android:maxWidth="100dp"
    android:maxHeight="100dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:layout_marginLeft="5.33dp"
    android:layout_toRightOf="@id/hero1"
    />

Is there anything that I am missing, I worked on this question for the past two days and can’t find any solution on internet or I am missing it. Help please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:21:21+00:00Added an answer on June 12, 2026 at 11:21 am

    The problem is in this line:

        ImageView img = (ImageView) findViewById(R.drawable.hero_frame);
    

    You need to pass the ID of the ImageView you want to find, you are probably getting a NullPointerException at the moment, because img can not be found, try something like this:

        ImageView img = (ImageView) findViewById(R.id.hero1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SOLVED I have a Flex/PHP app I'm working on. I have a single ArrayCollection
SOLVED in the last answer im getting following error, dunno where and why? cause
@Solved The two subquestions I have created have been solved (yay for splitting this
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
SOLVED: Thanks to @SJFrK, my issue has been solved. The following class allows me
** Solved ** I have a bit of a problem with my code i
[SOLVED - Provided example contains the answer!] I am trying to implement a program
------ SOLVED ------ Hi everyone, I have now solved this issue and it was
Solved the problem see the bottom of my post. So I have a simple
[SOLVED]: Applying proper list iteration procedure fixed problem. (Shown below) I currently have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.