On Aug 20, 9:15 pm, Nick Risaro <[email protected]> wrote:
> On Sat, Aug 20, 2011 at 10:03 PM, TreKing <[email protected]> wrote:
> > Stick an Image to the left of the title in your layout?
>
> With glue?

There is a TextView attribute called drawableLeft

e.g.

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android";
    android:id="@+id/mylistview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawableLeft="@drawable/icon" >
</TextView>

and your activity:

public class ListViewExampleActivity extends Activity {

        private ListView list;
        private String[] titles = {"title1", "title2", "title3", "title4"};

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                list = (ListView)findViewById(R.id.mylistview);
                list.setAdapter(new ArrayAdapter<String>(this, 
R.layout.list_item,
titles));
        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to