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. Encrypt files

Hi,

I need to encrypt some files but the user must have access to them in both
read/write

 

I would to create a virtual partition and mount it into a folder but how to
link an application with a folder ? or create a driver ?

 

If this approach can't run maybe with a live folder but I don't know how to
save new file into it 

If you have idea or different approach for this problem your are welcome 

 

Best regards,

Cyril Roques


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

2. notification

Hi all.
 
I'm just learning how to develop for android.  I'm using Eclispe Ganymede
3.4.1 with ADT 0.8.0.v200809220836-110569 and jdk 1.6.0_10.  I have created
a test app wherein I put some text and a button on the screen.  the program
loads and runs in the emulator just fine, but when I click the button, I
want it to give me some text feedback that the button was clicked, but
nothing happens.  Below is my java code:
 
package test.app;

import android.app.Activity;

import android.os.Bundle;

import android.widget.Button;

import android.view.View;

import android.view.View.OnClickListener; 

public class test_app extends Activity {

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

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        /* Find the button from our XML-layout. */

        Button b = (Button)this.findViewById(R.id.btn_open_search);

        b.setOnClickListener(new OnClickListener() {

            public void onClick(View agr0) {

            // Place code to handle button click here

            System.out.println("Button clicked");

            }

        });

    }

}

 

Is there a different way I should be doing this than using
system.out.println()?  Any suggestions are welcome.  Thanks.


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

3. Samsung Galaxy S 9003 dijual sebagai Galaxy S II?

4. [help] barnacle ga mau connect

5. Android phones

6. Swype Indonesia

7. Obtain ip address