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 8442703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:54:45+00:00 2026-06-10T08:54:45+00:00

I need to display images from res/drawable folder and put it in a imageview.

  • 0

I need to display images from res/drawable folder and put it in a imageview. I’ve done some research and implemented them. It only displays blank screen but no image.

My xml code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/mainlayout"
    />
</LinearLayout>

Java code:

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {   
        String value = extras.getString("FaType");

        if(value.equals("AnimalBite"))
        {
            LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainlayout);

            ImageView imageView = new ImageView(this);
            imageView.setImageResource(R.drawable.medrem);
            LayoutParams imageViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            imageView.setLayoutParams(imageViewLayoutParams);

            mainLayout.addView(imageView);

        }
}

CATLOG

08-21 20:54:35.698: E/Trace(684): error opening trace file: No such file or directory (2)
08-21 20:54:36.618: D/dalvikvm(684): GC_FOR_ALLOC freed 227K, 4% free 8142K/8455K, paused 123ms, total 142ms
08-21 20:54:36.948: D/dalvikvm(684): GC_CONCURRENT freed 196K, 4% free 8383K/8711K, paused 35ms+25ms, total 138ms
08-21 20:54:37.978: I/Choreographer(684): Skipped 199 frames!  The application may be doing too much work on its main thread.
08-21 20:54:38.158: D/gralloc_goldfish(684): Emulator without GPU emulation detected.
08-21 20:54:39.318: I/Choreographer(684): Skipped 64 frames!  The application may be doing too much work on its main thread.
08-21 20:54:47.318: I/Choreographer(684): Skipped 77 frames!  The application may be doing too much work on its main thread.
08-21 20:54:48.138: I/Choreographer(684): Skipped 45 frames!  The application may be doing too much work on its main thread.
08-21 20:54:49.798: D/AndroidRuntime(684): Shutting down VM
08-21 20:54:49.798: W/dalvikvm(684): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-21 20:54:49.848: E/AndroidRuntime(684): FATAL EXCEPTION: main
08-21 20:54:49.848: E/AndroidRuntime(684): java.lang.RuntimeException: Unable to start activity ComponentInfo{dr.droid/dr.droid.ImageViewer}: java.lang.NullPointerException
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.os.Looper.loop(Looper.java:137)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread.main(ActivityThread.java:4745)
08-21 20:54:49.848: E/AndroidRuntime(684):  at java.lang.reflect.Method.invokeNative(Native Method)
08-21 20:54:49.848: E/AndroidRuntime(684):  at java.lang.reflect.Method.invoke(Method.java:511)
08-21 20:54:49.848: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-21 20:54:49.848: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-21 20:54:49.848: E/AndroidRuntime(684):  at dalvik.system.NativeStart.main(Native Method)
08-21 20:54:49.848: E/AndroidRuntime(684): Caused by: java.lang.NullPointerException
08-21 20:54:49.848: E/AndroidRuntime(684):  at dr.droid.ImageViewer.onCreate(ImageViewer.java:29)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.Activity.performCreate(Activity.java:5008)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-21 20:54:49.848: E/AndroidRuntime(684):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-21 20:54:49.848: E/AndroidRuntime(684):  ... 11 more
08-21 20:54:52.268: I/Process(684): Sending signal. PID: 684 SIG: 9

Any ideas? I also need to know the problem of this code. Because whenever I try to addimages on my drawable folder and use it at this

imageView.setImageResource(R.drawable.medrem)

It doesn’t seem to recognize the image. 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-10T08:54:47+00:00Added an answer on June 10, 2026 at 8:54 am

    You have no setcontentview ?

    That means that your MainLayout havn’t been inflated, which results in the nullpointer exception thrown in your logfile.

    Either inflate it manually or setContentView(R.layout.xxxx);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display some images from a website into my tableview.I tried some
I need to grab a some images from a folder on a users computer
I display set of images(small). I need to show the larger image(300*300) at some
I need to display some images. And I want to slide out one image
I need to display 3 random images from SQLite database horizontally. Since it's impossible
In my android app I need to display in a gridview images from a
I need to display multiple images for a a car from a separate linked
In my WPF app i need to load some images. I only need to
I need to display multiple images from a database table and bind it to
I need to display array of images in a single view which have various

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.