CheckBox with Background attribute renders incorrectly?

by Droidnostics » Tue, 06 Oct 2009 01:18:10 GMT


Sponsored Links
 Beginners question: why does the CheckBox render the text (when setText is
invoked) behind the checkbox (instead of next to the checkbox) when an
background image is assigned?

Second question: how do I make it *not* render behind the checkbox (and
still use a background image)?

 

Layout code:

<?xml version="1.0" encoding="utf-8"?>

<CheckBox xmlns:android=" http://schemas.android.com/apk/res/android" ;

      android:id="@+id/check"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:text="This checkbox is: unchecked"

      android:background="@drawable/icon"

       />

 

 

Main class

import android.app.Activity;

import android.os.Bundle;

import android.widget.CheckBox;

import android.widget.CompoundButton;

import android.widget.CompoundButton.OnCheckedChangeListener;

 

public class TestCheckBox extends Activity implements
OnCheckedChangeListener 

{

      CheckBox m_checkBox;

      

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) 

    {

        super.onCreate(savedInstanceState); 

        setContentView(R.layout.main);

        

        m_checkBox = (CheckBox)findViewById(R.id.check);

     

        m_checkBox.setOnCheckedChangeListener(this);

    }

 

      public void onCheckedChanged(CompoundButton buttonView, boolean
isChecked) 

      {

            if (isChecked)

                  m_checkBox.setText("Checkbox is checked");

            else

                  m_checkBox.setText("Checkbox is unchecked");

      }

}


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



Other Threads

1. How can i import com.android.internal.phone?

Hi there,
I'm trying to invoke the functions belong to class phone and
PhoneFactory. But when I'm trying to import these packages, it reminds
errors:

code:
import com.android.internal.telephony.Phone
import com.android.internal.telephony.PhoneFactory
...
PhoneFactory.makeDefaultPhones(this)
Phone phone = PhoneFactory.getDefaultPhone()

error:
The com.android.internal.telephony.Phone can not be resolved.
The com.android.internal.telephony.PhoneFactory can not be resolved.

But some other packages can be imported. I don't know why. I think all
this packages should be included in the SDK.
Can any one tell me where I am getting wrong?
Thanks.
Nio
--~--~---------~--~----~------------~-------~--~----~

2. usb connection detection

Hi,
I need to write a customized mobile app on Gphone and also make a
windows driver to detect when the phone is connected to the phone to
start another desktop app on windows, this app will then start
transferring some data from the mobile app.  what's the best approach/
framework i should use here for the driver?
thanks
--~--~---------~--~----~------------~-------~--~----~

3. 1.5 SDK: "android list target" failed

4. How can i import com.android.internal.phone?

5. "send" intent only when activity is on top running

6. Accessing native service from an application

7. "send" intent only when activity is on top running