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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:21:46+00:00 2026-05-14T03:21:46+00:00

I have setup background image for a button as below. // declarations globally declared…

  • 0

I have setup background image for a button as below.

// declarations globally declared...
ImageButton sampleButton;
int sampleFirstImage = 0;
int sampleSecondImage = R.drawable.imageSecond;
......................................
......................................
sampleFirstImage = R.drawable.imageFirst;
sampleButton.setImageResource(sampleImage);

In certain cases, i want to replace this image with the another second image if the first image is set. As i need to check the condition as first image set or not for button, i need to know what image is already being set for the button. So i want to GET, image set for the button? Is there any API which gets image id set for a control?

Thanks. Appreciate if you know and can explain it to me!

  • 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-05-14T03:21:46+00:00Added an answer on May 14, 2026 at 3:21 am

    If you are setting the image yourself then you could consider adding a tag (setTag) whenever you set an image source.

    When you get the tag later you will know which image was last set.

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

Sidebar

Related Questions

Some setup background first: I have a cronjob which runs a PHP file called
Background: We have a TFS server setup where me manage our source code and
I had a simple button set up with a background image defined like android:background=?attr/button
I have customised the navigation controller title bar with a background image, but I
I have UINavigationBar setup as image - some wood texture. I want to insert
I have a complicated background image with a lot of small regions that need
i have the following situation (please see image below after reading the following): .dragoverlay
I have a button style defined like this: <style name=button_style> <item name=android:textColor>#ffffff</item> <item name=android:background>@drawable/button_on_red</item>
I have setup airbrake in my app but it doesn't seem to log any
I have setup ability for a user to specify some settings using the in-built

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.