我在使用列表首选项时遇到问题。我正在尝试使用 if 语句将列表首选项值与另一个值匹配
我打赌这没有意义,所以我会发布代码......
条纹主:
String stripeType = "";
void drawStriped() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
if (stripeType == "vert")
{
android.util.Log.d("stripedLog", "working");
}
}
} finally {
if (c != null)
holder.unlockCanvasAndPost(c);
}
.............
设置.xml:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:key="firKey"
android:title="Wallpaper Settings" >
<ListPreference
android:defaultValue="hor"
android:entries="@array/stripe_entries"
android:entryValues="@array/stripe_values"
android:key="stripe_type"
android:title="Type" />
</PreferenceCategory>
</PreferenceScreen>
形状.xml:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="stripe_entries">
<item>"Horizontal"</item>
<item>"Vertical"</item>
<item>"Both"</item>
<item>"Both+CrossOver"</item>
</string-array>
<string-array name="stripe_values">
<item>"hor"</item>
<item>"vert"</item>
<item>"both"</item>
<item>"bothOver"</item>
</string-array>
</resources>
这不起作用,我不知道为什么....