Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在线性布局内、弹出窗口内单击编辑文本_Android_Android Popupwindow - Fatal编程技术网

Android 无法在线性布局内、弹出窗口内单击编辑文本

Android 无法在线性布局内、弹出窗口内单击编辑文本,android,android-popupwindow,Android,Android Popupwindow,我有一个线性布局内的编辑文本。线性布局在弹出窗口中 运行应用程序时,我无法单击并输入编辑文本 弹出窗口的代码,它位于我的片段的onCreateView中: final Button makeoffer = (Button) view.findViewById(R.id.make_offer); makeoffer.setOnClickListener(new View.OnClickListener() { @Override public void on

我有一个线性布局内的编辑文本。线性布局在弹出窗口中

运行应用程序时,我无法单击并输入编辑文本

弹出窗口的代码,它位于我的片段的onCreateView中:

final Button makeoffer = (Button) view.findViewById(R.id.make_offer);
    makeoffer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LayoutInflater layoutInflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.offer_popup, null);
            final PopupWindow popupWindow = new PopupWindow(popupView,LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            EditText mEditText = (EditText) popupView.findViewById(R.id.payment_field);
            popupView.clearFocus();
            mEditText.requestFocus();
            popupWindow.setFocusable(true);
            popupWindow.update();

            final Spinner spinner1 = (Spinner) popupView.findViewById(R.id.transaction_spinner);
            spinner1.setAdapter(new ArrayAdapter<CharSequence>(getActivity(), R.layout.support_simple_spinner_dropdown_item,getActivity().getResources().getTextArray(R.array.payment_list)));

            Button btnDismiss = (Button)popupView.findViewById(R.id.cancel2);
            btnDismiss.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    popupWindow.dismiss();
                }
            });
            popupWindow.showAtLocation(popupView, Gravity.NO_GRAVITY, 0, 0);
        }
    }); 
final Button makeoffer=(Button)view.findviewbyd(R.id.make\u offer);
makeoffer.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
LayoutInflater LayoutInflater=(LayoutInflater)getActivity().getSystemService(Context.LAYOUT\u INFLATER\u SERVICE);
View popupView=LayoutFlater.充气(R.layout.offer\u弹出窗口,空);
final PopupWindow PopupWindow=新的PopupWindow(popupView、LayoutParams.MATCH_父项、LayoutParams.MATCH_父项);
EditText mEditText=(EditText)popupView.findViewById(R.id.payment_字段);
clearFocus();
mEditText.requestFocus();
popupWindow.setFocusable(真);
更新();
最终微调器微调器1=(微调器)popupView.findViewById(R.id.transaction_微调器);
spinner1.setAdapter(新的ArrayAdapter(getActivity(),R.layout.support_simple_spinner_dropdown_item,getActivity().getResources().getTextArray(R.array.payment_list));
按钮btnDismiss=(按钮)popupView.findViewById(R.id.cancel2);
btnDismiss.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
popupWindow.disclose();
}
});
popupWindow.showAtLocation(popupView,Gravity.NO_Gravity,0,0);
}
}); 
弹出窗口布局的XML代码:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:descendantFocusability="blocksDescendants"
android:layout_height="match_parent"
android:background="#BF000000">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textColor="#FFFFFF"
    android:textSize="25sp"
    android:layout_marginTop="120dp"
    android:text="Make an Offer"/>

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="60dp"
    android:orientation="horizontal"
    android:layout_marginLeft="40dp"
    android:layout_marginTop="20dp"
    android:layout_gravity="top|left"
    android:background="#FFFFFF"
    android:layout_marginBottom="20dp"
    android:descendantFocusability="blocksDescendants">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top|left"
        android:textColor="#00ff00"
        android:paddingLeft="10dp"
        android:paddingTop="5dp"
        android:text="Your Offer: "/>



        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textColor="#000000"
            android:textSize="18sp"
            android:paddingLeft="10dp"
            android:text="$"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="38sp"
        android:hint="Amount"
        android:id="@+id/payment_field"
        android:textColor="#000000"
        android:paddingLeft="5dp"
        android:background="#FFFFFF"
        android:layout_gravity="center_vertical"
        android:textColorHint="#000000"/>

    </LinearLayout>

<Spinner
    android:id="@+id/transaction_spinner"
    android:spinnerMode="dialog"
    android:layout_width="300dp"
    android:layout_height="50dp"
    android:popupBackground="#00688B"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="40dp"
    android:background="#FFFFFF"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:textColor="#00ff00"
    android:layout_marginLeft="100dp"
    android:textSize="15sp"
    android:paddingLeft="10dp"
    android:layout_marginBottom="15dp"
    android:text="How does this work?"/>

<Button
    android:layout_width="300dp"
    android:layout_height="40dp"
    android:layout_marginLeft="40dp"
    android:layout_marginTop="10dp"
    android:background="#228b22"
    android:text="Review Offer"
    android:inputType="textFilter"
    android:id="@+id/review_offer"
    android:textColor="#FFFFFF"
    android:layout_marginBottom="10dp"
    />
<Button
    android:layout_width="300dp"
    android:layout_height="40dp"
    android:layout_marginLeft="40dp"
    android:layout_marginTop="10dp"
    android:background="#FFFFFF"
    android:text="Cancel"
    android:inputType="textFilter"
    android:id="@+id/cancel2"
    android:textColor="#000000"
    android:layout_marginBottom="10dp"
    />


对于阅读本文的其他人:

非常感谢AnkiiRawat。 我所做的是在xml文件中去掉了android:genderantFocusability=“blocksDescendants”。在包含编辑文本的LinearLayout中,我添加了
android:DegenantFocusability=“AfterDegenders”属性。

您应该从editText的rootlayout中删除
android:DegenantFocusability=“BlocksDescents”
,因为通过添加此属性,LinearLayout将阻止其子体接收焦点。或者我建议您添加
android:genderantfocusability=“aftersenders”
@AnkiiRawat-android:genderantfocusability=“aftersenders”有效!我还去掉了xml文件中的android:genderantfocusability=“blocksDescendants”。非常感谢。