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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:03:28+00:00 2026-05-23T13:03:28+00:00

So i made these two buttons. I want to be able to click the

  • 0

So i made these two buttons.

I want to be able to click the button i made and have the button change to the whited-out image of the original button instead of on and off states you would have in a toggle button.

so far all I’ve figured out is something to do with stateListDrawable xml, which i placed in the 3 drawable folders. Thats the only place I’ve found it belongs, however, i don’t know where to reference the .xml file to the main. Do you do this programmatically? If so point me in the right direction of a good tutorial. The android dev page is foreign to me. And i would have posted the buttons so you would have a better idea, but i can’t until i get some more points. What a gimmick!

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true"
       android:drawable="@drawable/toggle_selection_pressed" />  
 <item android:drawable="@drawable/toggle_selection" />
</selector>
  • 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-23T13:03:29+00:00Added an answer on May 23, 2026 at 1:03 pm

    You’ll need a variable to keep the state of the button. Put this in the main class declaration

        int isClicked = 0;
    
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            if (isClicked == 0){
               Demo_button.setsetImageResource(R.drawable.secondimage);
               isClicked = 1;
            }
            else{
               Demo_button.setsetImageResource(R.drawable.firstimage);
               isClicked = 0;
            }
        }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two images. And... I made them into graysclae images and then
I have a list with rows containing two buttons. Button A in Row X
I have made a map of functions. all these functions are void and receive
I have made a simple chat application in PHP/Ajax/MySQL. I am regularly calling these
I have an array made of unlimited number of objects. These objects have the
I have made a simple form with one textField and command, I want to
What i have: I have a calculator layout, with many buttons. And each button
When I press a button I want to run another separate app I made,
I have two images for a button, one for normal, and one for selected.
I have just implemented these ToggleButtons using ControlTemplates that set the Image content according

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.