【问题标题】:Equivalent of plist in AndroidAndroid中plist的等价物
【发布时间】:2015-10-23 17:11:58
【问题描述】:

我在原生 iOS 平台上开发了一个应用程序,我正在从 plist 中读取用户设置。

string settingsBundle = NSBundle.MainBundle.PathForResource ("Settings.bundle/Root", @"plist");
NSDictionary dic = NSDictionary.FromFile (settingsBundle);

我想知道AndroidXamarin.Android 中的常用方法是什么

【问题讨论】:

标签: android ios xamarin


【解决方案1】:

您可以将默认用户设置放在preferences.xml 中:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="pref_sync"
        android:title="@string/pref_sync"
        android:summary="@string/pref_sync_summ"
        android:defaultValue="true" />
    <ListPreference
        android:dependency="pref_sync"
        android:key="pref_syncConnectionType"
        android:title="@string/pref_syncConnectionType"
        android:dialogTitle="@string/pref_syncConnectionType"
        android:entries="@array/pref_syncConnectionTypes_entries"
        android:entryValues="@array/pref_syncConnectionTypes_values"
        android:defaultValue="@string/pref_syncConnectionTypes_default" />
</PreferenceScreen>

然后这样读:

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String syncConnPref = sharedPref.getString(SettingsActivity.KEY_PREF_SYNC_CONN, "");

Defining Preferences in XML查看更多详情

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    • 2012-03-17
    • 2014-07-28
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多