我希望能够突出显示TextView
LinearLayout
中的ListView
中的文字,即android:focusable="false" android:focusableInTouchMode="false"
中的项目。 Android Marshmallow(6.0)运行正常,但6.0之前的任何其他功能都没有。我试过在另一个帖子上设置ListVeiw
,但没有运气(尝试使用true)。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:background="#fff">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/list_of_selectable_text_items"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="@dimen/feed_item_divider_height"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:background="@color/background"
android:padding="5dp"
android:transcriptMode="alwaysScroll" />
</LinearLayout>
看起来像这样:
LinearLayout
这是列表项<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="10dp"
android:paddingLeft="107dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
android:textColor="@color/dark_text"
android:id="@+id/selectable_text"
android:padding="10dp"
android:layout_gravity="right"
android:autoLink="all"
android:textIsSelectable="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="May 19 at 9:35am"
android:id="@+id/selectable_text_tiemstamp"
android:textColor="#666666"
android:layout_centerVertical="true"
android:layout_gravity="right" />
</LinearLayout>
:
public class PurchaseOrder : AggregateRoot<int>
{
private PurchaseOrder(int id, int supplierID, DateTime orderDate, int deliveryMethodID, int contactPersonID) : base(id)
{
SupplierID = supplierID;
OrderDate = orderDate;
DeliveryMethodID = deliveryMethodID;
ContactPersonID = contactPersonID;
}
public List<PurchaseOrderLine> PurchaseOrderLines { get; private set; }
public int SupplierID { get; private set; }
public DateTime OrderDate { get; private set; }
public int DeliveryMethodID { get; private set; }
public int ContactPersonID { get; private set; }
public static PurchaseOrder CreatePurchaseOrder(int supplierID, int deliveryMethodID, int contactPersonID)
{
return new PurchaseOrder(1, supplierID, DateTime.Now, deliveryMethodID, contactPersonID);
}
public void AddPurchaseOrderLine(int stockItemID)
{
PurchaseOrderLines.Add(new PurchaseOrderLine(this.Id, stockItemID));
}
}