Tampilkan postingan dengan label on and off. Tampilkan semua postingan
Tampilkan postingan dengan label on and off. Tampilkan semua postingan

Custom Toggle Button in ANDROID

Posted by Unknown Kamis, 20 Juni 2013 0 komentar
Toggle Button is a special button that has two states  for eg :"on" and "off".It can be an alternative to Radio Buttons.
Method to create a Custom Toggle Button is given below :

in custom_btn.xml






in style.xml :
 



in custom_toggle_bg.xml :




in custom_toggle_btn.xml :







Baca Selengkapnya ....

Toggle button in ANDROID - An alternative to radio button

Posted by Unknown Rabu, 19 Juni 2013 0 komentar
Toggle Button is a special button that has two states  for eg :"on" and "off".It can be an alternative to Radio Buttons.
Below are some methods mentioned in this example :
setOnClickListener – Used to register a callback whenever view is clicked
setChecked() – used to mark toggle button as checked/unchecked
setTextOn() – used to display text on toggle button whenever it is CHECKED
setTextOff() – used to display text on toggle button whenever it is UnCHECKED.

public class MainActivity extends Activity {
ToggleButton toggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

toggle = (ToggleButton) findViewById(R.id.togglebut);
// you can set text accordingly when checked or not
toggle.setTextOn("Toggle is Checked");
toggle.setTextOff("Toggle is not Checked");
// you can set if toggle to be checked or not
toggle.setChecked(true);
toggle.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (toggle.isChecked())
{
Toast.makeText(MainActivity.this, "is checked", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(MainActivity.this, "is not checked", Toast.LENGTH_SHORT).show();
}
}
});
} }


Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.