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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:18:26+00:00 2026-06-04T08:18:26+00:00

I am displaying image in the activity by calling other class but it is

  • 0

I am displaying image in the activity by calling other class but it is not displaying the image it is showing me the error.my code is as follow

public class VideosActivity extends Activity {
    //DrawView draw;
    float a=0;
    float b=0;
    ImageView image;
    MotionEvent event;
    Button  back ;
    Button next;
    TextView t;
    String info = "";
    int count =0;
    FirstImage  i= new FirstImage (this);
TableLayout tl;
TableRow ru,rm,rl,rlm;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.videos_layout);
         i=(FirstImage)findViewById(R.id.first);
         //back = (Button) findViewById(R.id.button1);
        // next = (Button) findViewById(R.id.button2);
        //
     // addListenerOnButton();


}



    private void addListenerOnButton() {
        // TODO Auto-generated method stub

        if (count == 0)
            back.setEnabled(false);

        next.setOnClickListener( new OnClickListener() {


            public void onClick(View arg0) {
                if(count==0){
                image.setImageResource(R.drawable.hand);
                back.setEnabled(true);
                count++;

                addListenerOnButton();

                }
                else if (count==1){
                    image.setImageResource(R.drawable.tissue);
                    count++;

                    addListenerOnButton();

                }

                else if (count==2){
                    image.setImageResource(R.drawable.cellconstfinal1);
                    count++;

                    addListenerOnButton();


                }
                else if (count==3){
                    //nucleus
                    image.setImageResource(R.drawable.cellconstfinal1);
                    count++;

                    addListenerOnButton();

                }
                else if (count==4){
                    //nchromosome
                    image.setImageResource(R.drawable.hand);
                    count++;

                    addListenerOnButton();

                }
                else
                {   //double helix
                    count++;
                    image.setImageResource(R.drawable.handash1);
                    next.setEnabled(false);

                    addListenerOnButton();

                }

            }
        });

        back.setOnClickListener(new OnClickListener() {


            public void onClick(View arg0) {
                if(count==1){
                    image.setImageResource(R.drawable.human);
                    back.setEnabled(false);
                    count--;

                    addListenerOnButton();

                    }
                    else if (count==2){
                        image.setImageResource(R.drawable.hand);
                        count--;

                        addListenerOnButton();

                    }

                    else if (count==3){
                        image.setImageResource(R.drawable.tissue);
                        count--;

                        addListenerOnButton();


                    }
                    else if (count==4){
                        image.setImageResource(R.drawable.cellconstfinal1);
                        count--;

                        addListenerOnButton();

                    }
                    else if (count==5){
                        //nucleus
                        image.setImageResource(R.drawable.tissue);
                        count--;

                        addListenerOnButton();


                    }
                    else {
                        //chromosome
                        //count==6
                        image.setImageResource(R.drawable.cellconstfinal1);
                        count--;

                        addListenerOnButton();
                        next.setEnabled(true);

                    }
                }
            });
    }

it is showing me the following error.i am not understanding why it is showing me following error.

05-10 19:27:32.097: E/AndroidRuntime(638): FATAL EXCEPTION: main
05-10 19:27:32.097: E/AndroidRuntime(638): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.androidtablayout/com.example.androidtablayout.VideosActivity}: java.lang.NullPointerException
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.widget.TabHost.setCurrentTab(TabHost.java:323)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.view.View.performClick(View.java:2408)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.view.View$PerformClick.run(View.java:8816)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.os.Handler.handleCallback(Handler.java:587)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.os.Looper.loop(Looper.java:123)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 19:27:32.097: E/AndroidRuntime(638):  at java.lang.reflect.Method.invokeNative(Native Method)
05-10 19:27:32.097: E/AndroidRuntime(638):  at java.lang.reflect.Method.invoke(Method.java:521)
05-10 19:27:32.097: E/AndroidRuntime(638):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 19:27:32.097: E/AndroidRuntime(638):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 19:27:32.097: E/AndroidRuntime(638):  at dalvik.system.NativeStart.main(Native Method)
05-10 19:27:32.097: E/AndroidRuntime(638): Caused by: java.lang.NullPointerException
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.view.View.<init>(View.java:1810)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.widget.ImageView.<init>(ImageView.java:103)
05-10 19:27:32.097: E/AndroidRuntime(638):  at com.example.androidtablayout.FirstImage.<init>(FirstImage.java:8)
05-10 19:27:32.097: E/AndroidRuntime(638):  at com.example.androidtablayout.VideosActivity.<init>(VideosActivity.java:27)
05-10 19:27:32.097: E/AndroidRuntime(638):  at java.lang.Class.newInstanceImpl(Native Method)
05-10 19:27:32.097: E/AndroidRuntime(638):  at java.lang.Class.newInstance(Class.java:1429)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-10 19:27:32.097: E/AndroidRuntime(638):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-10 19:27:32.097: E/AndroidRuntime(638):  ... 18 more
05-10 19:27:41.897: I/Process(638): Sending signal. PID: 638 SIG: 9

first image .jav code is present here ………..

public class FirstImage extends ImageView {
    public FirstImage(Context context) {
        super(context);
        // TODO Auto-generated constructor stub

    }




}

videos layout is code is as follow ….

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >


  <!--  Screen Design for VIDEOS -->
<TableLayout 
    android:id="@+id/tablelayout"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:stretchColumns="1">

     <TableRow
          android:id="@+id/tableRow1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" >

          <TextView
               android:id="@+id/textView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="15dip"
              android:text="pic on click which will tell where is the dna located in human body or cell "
              android:textSize="18dip" />
      </TableRow>

      <TableRow
          android:id="@+id/tableRow2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" >

          <FrameLayout 
        android:layout_width="wrap_content"
          android:layout_height="wrap_content">
        <com.example.AndroidTablayout.FirstImage
            android:id="@+id/first"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:src="@drawable/human"/>                                               
</FrameLayout>
      </TableRow>

      <TableRow
          android:id="@+id/tableRow3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" >

          <LinearLayout
              android:id="@+id/linearLayout1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" >

              <Button
                  android:id="@+id/button1"
                  android:layout_width="100dp"
                  android:layout_height="wrap_content"
                  android:text="Back" />

              <Button
                  android:id="@+id/button2"
                  android:layout_width="100dp"
                  android:layout_height="wrap_content"
                  android:text="Next" />

          </LinearLayout>

      </TableRow>
       <TableRow
          android:id="@+id/tableRow4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" >
          <TextView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="15dip"
              android:text="please don't mind  "
              android:textSize="18dip" />
          </TableRow>

  </TableLayout>
  </ScrollView>
  • 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-04T08:18:28+00:00Added an answer on June 4, 2026 at 8:18 am

    EDIT:
    Check this answer:

    custom image view android

    Maybe you need to implement the constructor with the AttributeSet parameter.

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

Sidebar

Related Questions

The following code is not displaying the image from IIS 6/PHP 5.2.9. It works
while restoring some data i am displaying a activity indicator..but i want the background
When i'm displaying image from url with using below code, application is taking too
I am displaying image by setting the source of an Image element directly to
I'm having trouble with displaying image from db. I think that method for saving
I'm displaying an image like this: <img src='counter.asp'> counter.asp is doing a hit-counter do
I am displaying an image in tableview cell (Image name saved in a plist).
i am working on displaying an image and placing an icon on top of
I am having trouble displaying an background image in my ASP.NET MVC 2 application.
I use the Remote File module for a cck field displaying a remote image.

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.