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

by chickenlives » Sun, 08 Mar 2009 14:43:06 GMT


Sponsored Links
 How do you change the color of a selected toggle button.  I'm
referring to the green line indicator which lights up when the button
is in the checked state.
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Database Creation in android

I want to know for some reason why my database is not being created. I
cannot see my database in the relevant folder after running the
project.

I have the following  code:

import android.content.ContentValues;
import android.content.Context;

import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import android.util.Log;

public class DBAdapter{

         public static final String KEY_ROWID = "_id";
            public static final String KEY_ISBN = "isbn";
            public static final String KEY_TITLE = "title";
            public static final String KEY_PUBLISHER = "publisher";
            private static final String TAG = "DBAdapter";

            private static final String DATABASE_NAME = "books";
            private static final String DATABASE_TABLE = "titles";
            private static final int DATABASE_VERSION = 1;

            private static final String DATABASE_CREATE =
                "create table titles (_id integer primary key autoincrement,
"
                + "isbn text not null, title text not null, "
                + "publisher text not null);";

            private final Context context;

            private DatabaseHelper DBHelper;
            private SQLiteDatabase db;

            public DBAdapter(Context ctx)
            {
                this.context = ctx;
                DBHelper = new DatabaseHelper(context);
            }

            private static class DatabaseHelper extends SQLiteOpenHelper
            {
                DatabaseHelper(Context context)
                {
                    super(context, DATABASE_NAME, null, DATABASE_VERSION);
                }

                @Override
                public void onCreate(SQLiteDatabase db)
                {
                    db.execSQL(DATABASE_CREATE);
                }

                @Override
                public void onUpgrade(SQLiteDatabase db, int oldVersion,
                int newVersion)
                {
                    Log.w(TAG, "Upgrading database from version " +
oldVersion
                            + " to "
                            + newVersion + ", which will destroy all old
data");
                    db.execSQL("DROP TABLE IF EXISTS titles");
                    onCreate(db);
                }
            }

            //---opens the database---
            public DBAdapter open() throws SQLiteException
            {
                db = DBHelper.getWritableDatabase();
                return this;
            }

            //---closes the database---
            public void close()
            {
                DBHelper.close();
            }

            //---insert a title into the database---
            public long insertTitle(String isbn, String title, String
publisher)
            {
                ContentValues initialValues = new ContentValues();
                initialValues.put(KEY_ISBN, isbn);
                initialValues.put(KEY_TITLE, title);
                initialValues.put(KEY_PUBLISHER, publisher);
                return db.insert(DATABASE_TABLE, null, initialValues);
            }

            //---deletes a particular title---
            public boolean deleteTitle(long rowId)
            {
                return db.delete(DATABASE_TABLE, KEY_ROWID +
                                "=" + rowId, null) > 0;
            }

            //---retrieves all the titles---
            public Cursor getAllTitles()
            {
                return db.query(DATABASE_TABLE, new String[] {
                                KEY_ROWID,
                                KEY_ISBN,
                                KEY_TITLE,
                        KEY_PUBLISHER},
                        null,
                        null,
                        null,
                        null,
                        null);
            }

            //---retrieves a particular title---
            public Cursor getTitle(long rowId) throws SQLiteException
            {
                Cursor mCursor =
                        db.query(true, DATABASE_TABLE, new String[] {
                                        KEY_ROWID,
                                        KEY_ISBN,
                                        KEY_TITLE,
                                        KEY_PUBLISHER
                                        },
                                        KEY_ROWID + "=" + rowId,
                                        null,
                                        null,
                                        null,
                                        null,
                                        null);
                if (mCursor != null) {
                    mCursor.moveToFirst();
                }
                return mCursor;
            }

            //---updates a title---
            public boolean updateTitle(long rowId, String isbn,
            String title, String publisher)
            {
                ContentValues args = new ContentValues();
                args.put(KEY_ISBN, isbn);
                args.put(KEY_TITLE, title);
                args.put(KEY_PUBLISHER, publisher);
                return db.update(DATABASE_TABLE, args,
                                 KEY_ROWID + "=" + rowId, null) > 0;
            }

}


And my Activity class is:

import android.app.Activity;
import android.os.Bundle;

public class DatabaseActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        DBAdapter db = new DBAdapter(this);


      //---add 2 titles---
        db.open();
        long id;
        id = db.insertTitle(
                        "0470285818",
                        "C# 2008 Programmer's Reference",
                        "Wrox");
        id = db.insertTitle(
                        "047017661X",
                        "Professional Windows Vista Gadgets Programming",
                        "Wrox");

        db.close();


    }
}
--~--~---------~--~----~------------~-------~--~----~

2. Out of surface memory in WVGA

I'm testing my application on WVGA854 emulator. I use two activities
with GL surface one is a menu and second is game itself. While
launching game in logcat there is a message about out of memory error
and application is killed:

10-24 12:42:49.860: DEBUG/Blockx.GameController(900): Surface created
10-24 12:42:49.890: ERROR/SurfaceFlinger(577): not enough memory for
layer bitmap size=1642496 (w=480, h=854, stride=480, format=1)
10-24 12:42:49.890: DEBUG/MemoryDealer(577):   LayerBitmap (0x2e9350,
size=8388608)
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     0: 002e9388 |
0x00000000 | 0x0003E000 | F
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     1: 00373ab0 |
0x0003E000 | 0x00191000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     2: 00373b78 |
0x001CF000 | 0x00191000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     3: 0028bd40 |
0x00360000 | 0x0003E000 | F
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     4: 002ce748 |
0x0039E000 | 0x00059000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     5: 002ce7c0 |
0x003F7000 | 0x00059000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     6: 00374bb0 |
0x00450000 | 0x00191000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     7: 00375ec8 |
0x005E1000 | 0x00059000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     8: 00377c30 |
0x0063A000 | 0x00059000 | A
10-24 12:42:49.890: DEBUG/MemoryDealer(577):     9: 00377d50 |
0x00693000 | 0x0016D000 | F
10-24 12:42:49.890: DEBUG/MemoryDealer(577):   size allocated: 6385664
(6236 KB)
10-24 12:42:49.900: ERROR/SurfaceFlinger(577): resizing buffer 1 to
(480,854) failed [fffffff4] Unknown error: -12
10-24 12:42:49.930: ERROR/SurfaceComposerClient(577): surface (id=0,
identity=12) is invalid, err=-12 (Out of memory)
10-24 12:42:49.940: WARN/WindowManager(577): Failure showing surface
Surface(native-token=3635864) in Window{43886518
com.beepstreet.blockx_trial/com.beepstreet.blockx_trial.GameActivity
paused=false}
10-24 12:42:49.940: INFO/WindowManager(577): Out of memory for
surface!  Looking for leaks...
10-24 12:42:49.960: WARN/WindowManager(577): No leaked surfaces;
killing applicatons!
10-24 12:42:49.960: WARN/ActivityManager(577): Killing processes for
memory at adjustment 0
10-24 12:42:49.960: WARN/ActivityManager(577): Killing for memory:
ProcessRecord{438d9618 900:com.beepstreet.blockx_trial/10023} (adj 0)
10-24 12:42:49.980: INFO/Process(577): Sending signal. PID: 900 SIG: 9
10-24 12:42:50.020: WARN/WindowManager(577): Looks like we have
reclaimed some memory, clearing surface for retry.
10-24 12:42:50.020: WARN/SurfaceComposerClient(577): Destroying
surface while a transaction is open. Client 0x2cc7a8: destroying
surface 0, mTransactionOpen=1

As I understand MemoryDealer debug dumps surface allocator structure
and indeed largest free block is smaller than requested 1642496 bytes.
My question is if same limit will be on real devices?

--
Bart (arcone1) Janusz
--~--~---------~--~----~------------~-------~--~----~

3. Raytheon Sends Android To Battlefield

4. Selling applications from outside the approved countries

5. Position in the market

6. Service stops?

7. GOOGLE MAPS ON ARCHOS 5