add image above listview in Android -
i've added listview activity. uses simple layout file follows:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" android:layout_gravity="center" > <textview android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:drawableleft="@drawable/greencircle" android:textsize="20sp" /> </linearlayout>
then add during "oncreate()":
string[] values = new string[] { "new contact", "list contacts", "edit settings"}; // use custom layout arrayadapter<string> adapter = new arrayadapter<string> (this, r.layout.activity_main_menu, r.id.label, values); setlistadapter(adapter); }
i need put image above listview i've not found works. there simple way of doing this?
just declare in xml?
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <imageview android:id="@+id/detailsico" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginright="10dp" android:layout_marginleft="10dp"/> <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="5dp" android:layout_marginbottom="5dp" android:divider="@android:color/transparent" android:dividerheight="7.0sp" > </listview> </linearlayout>
Comments
Post a Comment