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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:20:11+00:00 2026-06-01T18:20:11+00:00

i have a toggle button which when set to the on position sets the

  • 0

i have a toggle button which when set to the on position sets the hint to one of my textview to

“kg”

.
the initial hint of the text view is

“st”

which should be shown if the toggle is in the off position.

when i first start the app the textview dispalys

“st”

(which at first is ok as the toggle is in the off position) now when i press the toggle it turns to the on position and displays

“kg”

in the textView (this is also ok.)

now comes the problem. if i click on the toggle again (off position) the textView stays as

“kg”

does anyone know how i could set it to always display “st in the off state and “kg” in the on state.

many thanks in advance

addListenerOnButton();

      }

      public void addListenerOnButton() {

        unitToggle = (Button) findViewById(R.id.unitToggle);
       final TextView tw1 = (TextView)findViewById(R.id.tw1);


        unitToggle.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

               StringBuffer result = new StringBuffer();
               tw1.setHint("kg");
  • 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-01T18:20:12+00:00Added an answer on June 1, 2026 at 6:20 pm
     unitToggle.setOnClickListener(new OnClickListener() {
    
            public void onClick(View v) {
    
               StringBuffer result = new StringBuffer();
               if(tw1.getHint().toString().equals("kg"))
                    tw1.setHint("st");             
               else
                    tw1.setHint("kg");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button <a> that should toggle a drop-down Then it should also
I have a Main-Activity which displays several spinners. With a Toggle-Button in the Main-Activity
I'm using Javascript/Jquery to have a button toggle which div is displayed in the
Hello I have a Toggle button in Silverlight. I want to set its state
I have a button which when toggled displays/hides a div ('.reportOptions'), this works perfectly
I have a toggle button, with a show/hide feature in javascript. How do I
I have a button in my XML, that when clicked will toggle the visibility
I have a group of buttons that should act like toggle buttons, but also
I have a single button which I want to use as Start/Stop button. How
I have some JavaScript to toggle a dropdownlists in a ASP.NET page, which gets

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.