我以标准方式在我的 Android 应用程序中使用 SharedPreferences。在 HTC WildFire 设备(分辨率 240x320)上,显示虚拟键盘时 EditText 被挤压。
有没有其他人遇到过这个有解决方案吗?我被难住了好几天。
我的代码/XML 非常简单:
public class PrefsActivity extends PreferenceActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
// don't display hidden preferences
getPreferenceScreen().removePreference(findPreference("hidden_prefs"));
}
}
还有我的preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="User Preferences">
<EditTextPreference
android:key="profile"
android:title="Profile"
android:summary="Your profile name"
android:name="Profile"/>
<EditTextPreference
android:key="password"
android:title="Password"
android:summary="Your password"
android:name="Password"
android:password="true"/>
<EditTextPreference
android:name="Server"
android:summary="The server to use"
android:title="Server"
android:key="server"/>
<EditTextPreference
android:name="Secret"
android:summary="The server secret"
android:title="Secret"
android:password="true"
android:key="secret"/>
<CheckBoxPreference
android:title="On Demand"
android:defaultValue="true"
android:summary="Check to enable On Demand"
android:key="on_demand"/>
<ListPreference
android:title="Date"
android:summary="Set the type of date used"
android:key="date"
android:defaultValue="next"
android:entries="@array/prefs_date_keys"
android:entryValues="@array/prefs_date_values" />
</PreferenceCategory>
<PreferenceCategory android:key="hidden_prefs" android:title="Hidden Preferences">
<EditTextPreference
android:name="Last Project ID"
android:summary="The last Project ID"
android:title="Last Project ID"
android:key="last_project_id"
android:inputType="number"/>
<EditTextPreference
android:name="Fast Sync"
android:summary="Use Fast Sync"
android:title="Fast Sync"
android:key="fast_sync"
android:inputType="number"/>
</PreferenceCategory>