How to use Toggle Button in Android

How to use Toggle Button in Android from the best Training Institute

Create an Android Application name as ToggleButtonDemo.

Open activity_main.xml insert the each one Toggle Button and Button name as Submit.

After that come into page. Create a global object for toggle and submit button.

And inside the onCreate method connect with the widget function to the java page like follow

then set the onClickListener for the submit button for when user click the submit button do some action behind the code on this event.


Next create a StringBuilder class and its object used to get the values whether the toggle button is on or off status.

StringBuilder result = new StringBuilder();

result.append(“TogguleButton :”).append(tbtn.getText().toString());

Toast.makeText(MainActivity.this, result, Toast.LENGTH_SHORT).show();


The string object “result” get the status of toggle button that will display using Toast widget. Then Click the run button or right click the project from project explore -> run as -> Android Application. The result will display in emulator.

Emulator shows the default first page of app like this.

After the click button when toggle is off the Toast result will display “ToggleButton: OFF” then click the Toggle button it will turn on then click again the click button result like “ToggleButton: ON”.

Thank you. This Android Application App designed & created by the XPLORE IT CORP Coimbatore.

September 8, 2017

7 responses on "How to use Toggle Button in Android"

  1. Valuable information. Lucky me I found your site by accident, and I am shocked why this accident did not happened earlier! I bookmarked it. gckccccdbdeg

  2. Howdy! I basically would like to give a huge thumbs up for the good data you’ve got here on this post. I will probably be coming once again to your weblog for far more soon. edkedebgeeccgaek

  3. Im grateful for the blog article.Much thanks again. Cool. dgcgddeebeeg

  4. very nice post, i certainly love this web site, keep on it edfkekddffffeade

  5. Hello There. I found your blog using msn. This is a really well written article. Ill make sure to bookmark it and return to read more of your useful information. Thanks for the post. I will definitely return. bgadcebbeekc

  6. I’m really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, its rare to see a great blog like this one these days.. aacdaceeekeeeabe

Leave a Message

Your email address will not be published. Required fields are marked *

About Xplore IT Corp

XIC is home to several global certified trainers who are subject matter experts in their respective domains. XIC has Vast experienced resources who are top experts including that of Microsoft, Cisco, Oracle, VMware, Red Hat, Novell, EC Council, Adobe, among others.

© Xplore IT Corp 2017. All rights reserved. Designed by Web Design Company
Xplore WhatsApp Chat
Send via WhatsApp