i’d like to start by saying that im quite new to android developing.
my question is how can i change my below examples to allow text on both the left and right side of each list item.
my aim is to have each list item have an item description on the left, and a numeric value for that description on the right.
all i have up to now is a list that shows the values which i want showing on the left of each item.
main java activity (NewtestActivity.java):
public class NewtestActivity extends Activity {
String[] exampleList = {
"Item 1",
"Item 2",
"Item 3",
"Test 4",
"Item 5",
"Test 6",
"Item 7",
"Test 8"
//etc etc
};
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get an instance of your listview in code
ListView listview = (ListView) findViewById(R.id.list);
// Set the listview's adapter
listview.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, exampleList));
}
}
main.xml:
<?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"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="280dp"
android:layout_height="fill_parent"
>
<ImageView
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginLeft="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginLeft="5dp"
android:text="@string/app_name"
/>
</LinearLayout>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="200dp"
/>
</LinearLayout>
thanks for any help (:
want
Check this example