How to change the selected color (default green) of a toggle button

by Marco Nelissen » Mon, 09 Mar 2009 00:36:14 GMT


Sponsored Links
 You're talking about a CheckBox, which is derived from CompoundButton,
which is a button with two states. If you want to change how it looks,
you can specify your own Drawable for it, and either change it
yourself when the button changes state, or let the system do it for
you by specifying a drawable that has two states.





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Fetch Spinner value outside setOnItemSelectedListener

Hi guys,

I have a spinner successfully working but I am trying to use the
spinner.setSelection method to "remember" the previous spinner value
when the activity is reloaded.

Outside of setOnItemSelectedListener, is there a function of the
spinner that can give me the selected index?

The following code is my function code to both setup the spinner and
then my attempt to set the spinner with the index previously selected:

private void setSpinner(int spinnerID){
                final Spinner spinner   =
(Spinner)findViewById(R.id.Spinner_gender);
                int spinner_value;


                spinner.setOnItemSelectedListener(
                                new AdapterView.OnItemSelectedListener() {
                                        public void 
onItemSelected(AdapterView<?> parent, View
itemSelected, int selectedItemPosition, long selected){
                                                spinner_value   =       
selectedItemPosition;
                                                Editor editor   =       
mGameSettings.edit();
                                                
editor.putLong(GAME_PREFERENCES_GENDER,
selectedItemPosition);
                                                editor.commit();
                                                
Toast.makeText(QuizSettingsActivity.this, "selected:
"+GAME_PREFERENCES_GENDER+"("+ spinner_value +")",
Toast.LENGTH_SHORT).show();
                                        }

                                                @Override
                                                public void 
onNothingSelected(AdapterView<?> arg0) {
                                                        // TODO Auto-generated 
method stub

                                                }

                                        }
                );

                ArrayAdapter<?> adapter =       
ArrayAdapter.createFromResource(this,
spinnerID, android.R.layout.simple_spinner_item);
 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                spinner.setAdapter(adapter);
                if( mGameSettings.contains(GAME_PREFERENCES_GENDER) ){
                        spinner.setSelection(spinner_value);
                }

        }

All I am trying to do here is use spinner_value to remember the
selected index so I can set the spinner to that index.
However, the spinner_value is never holding the desired value at
spinner.setSelection(spinner_value); in the last lines of code

-- 

2. Mod: Ericsson Applications Awards

Ayo para developer android, mari unjuk kebolehan, semoga menang

-
Salam,

-
Agus Hamonangan


<

3. Three ListViews side by side

4. Droid Pro on sale a little early, shipping now

5. TUTORIAL FROYO JIT ON MILESTONE XT720

6. ADT painstakingly remove my exclusion setting for android library

7. Code for capturing screenshot of lock screen without DDMS