Reputation: 321
I am using Xamarin and have a ListView with a CustomAdapter for a Custom Row.
Here is the code for the CustomAdapter:
public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = items[position];
View view = convertView;
if (view == null)
view = context.LayoutInflater.Inflate(Resource.Layout.MapLocationDetail, null);
view.FindViewById<TextView>(Resource.Id.TextViewMapHeading).Text = item.Heading;
view.FindViewById<TextView> (Resource.Id.TextViewDescription).Text = item.SubHeading;
view.FindViewById<ImageView>(Resource.Id.Image).SetImageResource(item.ImageResourceId);
return view;
}
Here is the layout code for MapLocationDetail:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:background="#ffffffff">
<LinearLayout
android:id="@+id/Text"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dip">
<TextView
android:id="@+id/TextViewMapHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="80 Chesterton Street"
android:textColor="#ff000000" />
<TextView
android:id="@+id/TextViewDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="This is a description"
android:textColor="#ff000000"
android:autoLink="all" />
</LinearLayout>
<ImageView
android:id="@+id/Image"
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="5dp"
android:src="@drawable/icon"
android:visibility="invisible"
android:layout_alignParentRight="true" />
</RelativeLayout>
When the items are added to the ListView, there is no line or border between each item. How can I add a border to each item, or if not a border, a separating line between each item?
I have tried this with no result:
<?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">
<ListView
android:id="@+id/List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#FFFF"
android:dividerHeight="1dp"
android:background="#ffffffff" />
</LinearLayout>
Thanks in advance
Upvotes: 0
Views: 4327
Reputation: 14628
It's about the color you are using, the background and divider are both white, so you can't see the divider, change the divider to another color.
Upvotes: 2