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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:54:26+00:00 2026-06-15T17:54:26+00:00

I have a program which uses view flipper I am getting a NullPointerException as

  • 0

I have a program which uses view flipper I am getting a NullPointerException as follows when the activity is called. I wish to cycle through a set of images as long as the activity is being run.

06-13 18:52:05.358: E/AndroidRuntime(368): Caused by: java.lang.NullPointerException

Activity:

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.ViewFlipper;


public class MainMenuActivity extends Activity{

     Handler handler;
     Runnable runnable;
     ViewFlipper imageSwitcher;
    @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.menupage);

            imageSwitcher= (ViewFlipper) new ViewFlipper(this).findViewById(R.id.sportspersons);
            this.viewchanger();

        }

    public void viewchanger()
    {
        imageSwitcher.setInAnimation(this, R.anim.fadein);  
        imageSwitcher.setOutAnimation(this, R.anim.fadeout); 

        ImageView i = new ImageView(this);
        i.setBackgroundDrawable(getResources().getDrawable(R.drawable.jowens));
        ImageView i2 = new ImageView(this);
        i2.setBackgroundDrawable(getResources ().getDrawable(R.drawable.maradonna));
        ImageView i3 = new ImageView(this);
        i2.setBackgroundDrawable(getResources().getDrawable(R.drawable.mjordan));
        ImageView i4 = new ImageView(this);
        i2.setBackgroundDrawable(getResources().getDrawable(R.drawable.pele));
        imageSwitcher.addView(i);
        imageSwitcher.addView(i2);
        imageSwitcher.addView(i3);
        imageSwitcher.addView(i4);

        runnable = new Runnable() {

            @Override
            public void run() {
                handler.postDelayed(runnable, 3000);
                imageSwitcher.showNext();

            }
        };
        handler.postDelayed(runnable, 500);
    }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
      <ImageView
        android:id="@+id/imageView2"
        android:layout_width="match_parent"
        android:layout_height="508dp"
        android:layout_x="-4dp"
        android:layout_y="-5dp"
        android:scaleType="fitXY"
        android:src="@drawable/mainmenu01" />

        <ViewFlipper 
           android:id="@+id/sportspersons"  
           android:layout_width="86dp"
           android:layout_height="91dp"
           android:layout_x="38dp"
        android:layout_y="373dp" />  
</AbsoluteLayout>
  • 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-15T17:54:27+00:00Added an answer on June 15, 2026 at 5:54 pm

    You can try this way:

    runnable = new Runnable() {

            @Override
            public void run() {
                handler.postDelayed(runnable, 3000);
                imageSwitcher.setAutoStart(true);  
                imageSwitcher.startFlipping();
            }
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which uses a DLL called spreadsheetgear.dll In Visual Studio C#
I have a multithreaded program which uses pthread mutexes for synchronization on few integers.
I have a C program which uses Lua for scripting. In order to keep
I have avery simple program which uses MediaPLayer. I am new to java and
Below, I have a simple program which uses the CImg library (http://cimg.sourceforge.net/) which iterates
I have a Java 3D program which uses lots (hundreds) of 3D models (3ds
I have a simple program (written in Java) which uses the google protocol buffer
I have been trying to create a simple program with Python which uses OpenCV
Say, if I have a Lisp program, which uses (eval 'sym) and looks it
I have a small Python program, which uses a Google Maps API secret key.

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.