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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:45:48+00:00 2026-06-16T05:45:48+00:00

I am new in android field. I am working on to display two images

  • 0

I am new in android field. I am working on to display two images in center in my main.xml periodically. The code is running successfully but it didn’t show any image. Here is the code.

  package com.example.radio;
   import java.io.IOException;
   import java.util.Timer;
   import java.util.TimerTask;

   import android.app.Activity;
   import android.graphics.Bitmap;
   import android.graphics.BitmapFactory;
   import android.os.Bundle;
   import android.os.Handler;
   import android.os.Message;
   import android.util.Log;
   import android.widget.ImageView;

    public class Radio extends Activity 
    {
private ImageView _imagView;
private Timer _timer;
private int _index;
private MyHandler handler;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_radio);
    handler= new MyHandler();
    _imagView=(ImageView) findViewById(R.id.speak);

    _index=0;
    _timer= new Timer();
    _timer.schedule(new TickClass(), 500, 200);
}

private class TickClass extends TimerTask
{
    @Override
    public void run() {
        // TODO Auto-generated method stub
        handler.sendEmptyMessage(_index);
        _index++;
    }
}

private class MyHandler extends Handler
{
    @Override
    public void handleMessage(Message msg) {
        // TODO Auto-generated method stub
        super.handleMessage(msg);

        try {
                Bitmap bmp= BitmapFactory.decodeStream(Radio.this.getAssets().open("drum_"+_index+".png"));
                _imagView.setImageBitmap(bmp);

                Log.v("Loaing Image: ",_index+"");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Log.v("Exception in Handler ",e.getMessage());
        }
    }}}
  • 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-16T05:45:49+00:00Added an answer on June 16, 2026 at 5:45 am

    You can use the below sample code in you application and replace the drawables… It works fine for your requirement…

    int cargallery[] = { R.drawable.ford_suv_black,
                R.drawable.lincoln_town_car_black };
        int carIndex = -1;
        public static final int UPDATE_IMAGE = 1000;
        ImageView carimage = null;
    
    private Handler mHandler = new Handler() {
            public void handleMessage(Message msg) {
                if (msg.what == UPDATE_IMAGE) {
                    if (carIndex >= cargallery.length - 1) {
                        carIndex = -1;
                    }
                    carIndex++;
    
                    carimage.setImageResource(cargallery[carIndex]);
                    reloadCarImage();
                }
            };
        };
    
        private void reloadCarImage() {
    
            Message msg = new Message();
            msg.what = UPDATE_IMAGE;
            mHandler.sendMessageDelayed(msg, 1000);
        }
    
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.homescreen);
            carimage = (ImageView) findViewById(R.id.carview);
            reloadCarImage();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following below code to create expandablistView in android withour xml layout.its working
I am new in this field. I am working on Android application development. I
When I start a new Android project in Eclipse (Helios), the strings.xml has 2
I am a new BB developer working on android simultaneously, I am preparing a
I am new to Android and Eclipse development, but not new to software development
In the beginning: I am new in Android and Java programming, but I have
I am working on an android project and have an XML file for the
I am working in android.In my project there is a JSON parsing field for
I am new to Android Mono programming, but I have what is probably a
I am new to Android programming, now I am trying to place images inside

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.