我有一个对话框,我从自定义PopupDialog扩展。
问题是键盘不会出现在焦点EditText字段上。我尝试过使用clearFlags和其他东西,但问题仍然存在。
public class PopupDialog<RESULT> extends AlertDialog {
private final View mContentView;
private final AppActivity mActivity;
/**
* Sets the activity and Content View.
*
* @param activity
* The activity which is used.
* @param content
* The main content of dialog window.
*/
public PopupDialog(final AppActivity activity, final int content) {
super(activity);
mActivity = activity;
// Set the content
mContentView = getLayoutInflater().inflate(R.layout.z__dialog, null, false);
setView(mContentView);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
setView(mContentView, 0, 0, 0, 0);
// Set the background to white
setInverseBackgroundForced(true);
getWindow().setBackgroundDrawableResource(R.color.transparent);
show();
// Inflate the content
View.inflate(activity, content, (ViewGroup) findViewById(R.id.dialog_content)).setLayoutParams(new LinearLayout.LayoutParams(700, LayoutParams.WRAP_CONTENT));
}
答案 0 :(得分:0)
我猜你的EditText无法调焦或者在触摸模式下无法调焦,但在没有看到该视图的xml的情况下无法确定。你能发贴吗?
答案 1 :(得分:0)
我在xml中添加了一个EditText,并在代码this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
现在正在运作。不干净,但它正在发挥作用。
<LinearLayout
android:id="@+id/dialog_frame"
style="@style/vertical"
android:gravity="center" >
<requestFocus />
<FrameLayout
android:id="@+id/dialog_content"
style="@style/block" />
<EditText
android:id="@+id/editext"
style="@style/block"
android:focusable="false"
android:focusableInTouchMode="false"
android:visibility="gone" />
<LinearLayout
android:id="@+id/dialog_buttons"
style="@style/horizontal"
android:layout_width="wrap_content"
android:paddingBottom="@dimen/padding_middle" />
</LinearLayout>