共享preferences的EditText对话框挤压在HTC野火 [英] SharedPreferences EditText dialog squashed on HTC WildFire

查看:178
本文介绍了共享preferences的EditText对话框挤压在HTC野火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是共享preferences在我的标准方式Android应用程序。在HTC野火设备(分辨率240×320),该的EditText被压扁了,显示虚拟键盘的时候。

I'm using SharedPreferences in my Android app in the standard way. On the HTC WildFire device (resolution 240x320), the EditText is squashed up when the virtual keyboard is displayed.

有任何人碰到这个有没有解决办法?我已经难住了好几天。

Has anyone else come across this is there a solution? I've been stumped for days.

我的code / XML是pretty的简单:

My code/XML is pretty straightforward:

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:

And my 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>

推荐答案

我知道这个答案最有可能来得太迟,但如果其他人正在寻找一个解决方案,这个真正恼人的问题,这是我的工作围绕它,试图保持它的香草为可能的(对我来说,自定义布局是一个明确的禁忌在这种情况下):

I know this answer most likely comes too late, but in case anyone else is looking for a solution to this truly annoying problem, this is how I worked around it, trying to keep it as vanilla as possible (to me, custom layouts were a definite no-no in this case):

public class MyEditTextPreference extends EditTextPreference
{
    public MyEditTextPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void showDialog(Bundle bundle) {
        super.showDialog(bundle);

        Dialog dialog = getDialog();
        if(dialog != null) {
            Window window = dialog.getWindow();
            window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE |
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
    }
}

使用这个code,屏幕上的键盘会显示在对话框的按钮上方,但的EditText 仍然可见。

  • 截图1 (股份安卓的EditText preference)
  • 截图2 (MyEditText preference)
  • Screenshot 1 (Stock Android EditTextPreference)
  • Screenshot 2 (MyEditTextPreference)

这篇关于共享preferences的EditText对话框挤压在HTC野火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆