Try using this one: http://d.android.com/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds(android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable)
or directly in xml: <Button android:text="@+id/Button01" android:id="@+id/Button01" android:drawableLeft="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content"> </Button> R/ On Sun, Oct 4, 2009 at 3:26 PM, erisa <baw...@ucdavis.edu> wrote: > > I cann ot seem to get an icon and text on a button using set > drawables. The following code displays just the text; no icon. Any > ideas? > > package com.example.hellodrawable; > > import android.app.Activity; > import android.os.Bundle; > import android.widget.Button; > > public class HelloDrawable extends Activity { > /** Called when the activity is first created. */ > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > Button button = (Button) findViewById(R.id.Button01); > button.setCompoundDrawables(getResources().getDrawable > (R.drawable.icon), null, null, null); > button.setText("Hello"); > } > } > > main.xml is simply > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > > <Button android:text="@+id/Button01" > android:id="@+id/Button01" > android:layout_width="wrap_content" > android:layout_height="wrap_content"> > </Button> > </LinearLayout> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---