Answer the question
In order to leave comments, you need to log in
Changing the view of a custom item in a ListView?
I make custom items for the ListView in this way:
adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.product_name, constants);
lv.setAdapter(adapter);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listitem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4d73ff"
android:orientation="vertical" >
<TextView
android:id="@+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minHeight="48dp"
android:padding="10dp"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
With such an adapter, you can programmatically change it only when you click on item.
Implement the getView(int position, View convertView, ViewGroup parent) method and you
have full control.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question