我试图在偏好设置屏幕中显示一些彩色文字。 为此,我要创建一个这样的Spannable:
final String completeString = title + " - " + (TextUtils.isEmpty(currentValue) ? "?" : currentValue);
SpannableString span = new SpannableString(completeString);
span.setSpan(new ForegroundColorSpan(CURRENT_VALUE_COLOR), title.length() + 3, completeString.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span.setSpan(new StyleSpan(Typeface.BOLD), title.length() + 3, completeString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
myPref.setSummary(span);
当我的Preference位于PreferenceActivity主屏幕时,它可以正常工作,但当它在不同的PreferenceScreen中时,它的颜色不再显示
因此,例如,在这种情况下更改pref1摘要可以正常工作:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/cat1" >
<EditTextPreference
android:key="pref1"
android:summary="@string/pref1_summary"
android:title="@string/pref1_title" />
</PreferenceCategory>
</PreferenceScreen>
但在以下情况下会失败:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/cat1" >
<PreferenceScreen
android:summary="@string/prefSubScreen1" >
<ListPreference
android:key="pref1"
android:summary="@string/pref1_summary"
android:title="@string/pref1_title"
... /&GT;
知道如何让它发挥作用吗?
编辑:事实上,它看起来与Preference在不同的PreferenceScreen中无关。在ListPreference的情况下似乎失败了。为什么ListPreference无法将Spannable显示为摘要。
答案 0 :(得分:0)
您可以在.container {
line-height: 1.2em;
margin: 2em;
}
.arrow {
position: relative;
display: inline-block;
cursor: pointer;
width: 35px;
}
.arrow::before {
content: '';
display: block;
position: absolute;
top: 50%;
border: 2px solid orange;
width: 8px;
height: 8px;
transform: translateY(-50%) rotate(45deg);
}
.arrow::after {
content: '';
display: block;
position: absolute;
height: 2px;
width: 20px;
top: -1px;
right: 8px;
background-color: orange;
}
.arrow--left::before {
left: 8px;
border-right: 0;
border-top: 0;
}
.arrow--right::before {
right: 10px;
border-left: 1px;
border-bottom: 1px;
}
.arrow:hover:before {
border-color: black;
}
.arrow:hover:after {
background: #000;
}
<div class="container">
<div class="arrow arrow--left"></div>
<div class="arrow arrow--right"></div>
</div>
并在您的//Code
using System.Net;
using Microsoft.SharePoint.Client;
using (ClientContext context = new ClientContext("http://yourserver.sharepoint.com/")) {
context.Credentials = new NetworkCredential("user", "password", "domain");
List announcementsList = context.Web.Lists.GetByTitle("List A");
// This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
// so that it grabs all list items, regardless of the folder they are in.
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = announcementsList.GetItems(query);
// Retrieve all items in the ListItemCollection from List.GetItems(Query).
context.Load(items);
context.ExecuteQuery();
foreach (ListItem listItem in items)
{
// We have all the list item data. For example, Title.
label1.Text = label1.Text + ", " + listItem["Title"];
//label2.Text = label2.Text + ", " + listItem["Emp_x0020_ID"];
//EMP_x0020_ID could be internal name of SharePoint list column "EMP ID"
//Likewise check the column internal name for all the columns
//To find internal name, go to list settings and click each column
//you will see towards the end of the url something like &Field=Emp_x0020_ID
//"Emp_x0020_ID" is the internal name of the field
}
}
style.xml
对我有用。