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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:10:14+00:00 2026-06-17T01:10:14+00:00

I am using ImageView in my example. I set Images as background of imageview

  • 0

I am using ImageView in my example. I set Images as background of imageview in xml. Now I want to change this image background of Imageview at run time.

this is my java code.

 changeImage()

       {
       ImageView imgview=(ImageView)findViewById(R.id.imageView1);
       imgview.setImageResource(R.drawable.headerhindi);
       }

I am calling this method from onCreate(). First time my method works fine. but when I redirect again to my activity onCreate() using startActivity(myActivityIntent); this method does not works properly means Images does not change according to this method. By default images which is set in xml is shown.

Please help me to find out the solution.
Thank you in advance.

  • 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-17T01:10:16+00:00Added an answer on June 17, 2026 at 1:10 am

    Try moving the call to changeImage() to onResume().

    I haven’t tested it, but I have a feeling that what’s happening is that when you call startActivity() to start the activity again, the activity was not destroyed yet so onCreate() is not called again as per the activity lifecycle:

    enter image description herehttp://developer.android.com/images/activity_lifecycle.png. Just a hunch though.

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

Sidebar

Related Questions

I just want to set a text in a textView from strings.xml using java
I am assigning to an ImageView contacts images using this code: mPhotoView = (ImageView)
Grabbing album art for current song and using it to change a certain imageView.image
I tried using the following code in .java(main activity): final ImageView diskView1 = (ImageView)
I am using the following code to rotate a image in ImageView by an
I'm using the following function to load a remote image to an ImageView. The
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
I am using image view and gallery in my xml file. i am getting
I'm using a sectioned TableView, and I want to show an image on the
I am using RelativeLayout for put a textview on image for example, the problem

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.