Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.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 - Fatal编程技术网

Android 自定义对话框中的微调器提供强制关闭

Android 自定义对话框中的微调器提供强制关闭,android,Android,警报对话框显示得很好,当我单击微调器(微调器在警报对话框中)时,它会提供force close(强制关闭)帮助 private void showDialogue(Activity a) { try { // Inflating a layout for Alert Dialog LayoutInflater layoutInflater = (LayoutInflater) getApplicationCo

警报对话框显示得很好,当我单击微调器(微调器在警报对话框中)时,它会提供force close(强制关闭)帮助

private void showDialogue(Activity a) {
        try {
                        // Inflating a layout for Alert Dialog
            LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.prop_dialogue,null);
            view.findViewById(R.id.dialogue_btn_cancel).setOnClickListener(
                    Properties.this);
// Getting reference of Spinner      
   Spinner spin = (Spinner) view.findViewById(R.id.dialogue_spinner_count);
            setImage((ImageView) view.findViewById(R.id.dialogue_prop_icon),
                    getImageBitmap(position));
            setName((TextView) view.findViewById(R.id.dialogue_prop_name));
// Adapter for Spinner
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                Properties.this, R.array.prop_count,
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spin.setAdapter(adapter );
             spin.setOnItemSelectedListener(Properties.this);
            Builder b = new AlertDialog.Builder(this).setTitle("Properties")
                    .setNeutralButton("Submit",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog,
                                        int which) {

                                }
                            });
            b.setView(view);
            b.show();
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
protecteddialog onCreateDialog(int-id){
对话;
开关(id){
案例对话框\u发送\u PM:
微调器微调器=(微调器)findViewById(R.id.pm_服务器);
ArrayAdapter=ArrayAdapter.createFromResource(这个,R.array.server\u数组,android.R.layout.simple\u微调器\u项);
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
旋转器。设置适配器(适配器);
spinner.setOnItemSelectedListener(新的MyOnItemSelectedListener())
dialog=新对话框(PM.this);
setContentView(R.layout.send\u pm\u对话框);
setTitle(R.string.send_pm);
pmMessage=(EditText)dialog.findViewById(R.id.send\u pm\u框);
按钮sendPm=(按钮)dialog.findviewbyd(R.id.send\u pm\u按钮);
sendPm.setOnClickListener(PM.this);
打破
违约:
dialog=null;
}

代替AlertDialog.Builder(此)尝试AlertDialog.Builder(a),换句话说,将您的活动放入其中。您没有将arrayAdapter值传递给自定义微调器控件。在阵列适配器中,您使用默认微调器控件,但为自定义微调器添加触摸选择的侦听器。
06-06 12:09:22.971: E/AndroidRuntime(992): FATAL EXCEPTION: main
06-06 12:09:22.971: E/AndroidRuntime(992): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.ViewRoot.setView(ViewRoot.java:509)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.Dialog.show(Dialog.java:241)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.widget.Spinner.performClick(Spinner.java:257)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.View$PerformClick.run(View.java:8816)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Handler.handleCallback(Handler.java:587)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Looper.loop(Looper.java:123)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-06 12:09:22.971: E/AndroidRuntime(992):  at java.lang.reflect.Method.invokeNative(Native Method)
06-06 12:09:22.971: E/AndroidRuntime(992):  at java.lang.reflect.Method.invoke(Method.java:521)
06-06 12:09:22.971: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-06 12:09:22.971: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-06 12:09:22.971: E/AndroidRuntime(992):  at dalvik.system.NativeStart.main(Native Method)
protected Dialog onCreateDialog(int id){    
    Dialog dialog;
    switch(id) {

    case DIALOG_SEND_PM:
        Spinner spinner = (Spinner)findViewById(R.id.pm_server);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.server_array, android.R.layout.simple_spinner_item);             
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener())

        dialog = new Dialog(PM.this);
        dialog.setContentView(R.layout.send_pm_dialog);
        dialog.setTitle(R.string.send_pm);
        pmMessage = (EditText) dialog.findViewById(R.id.send_pm_box);
        Button sendPm = (Button) dialog.findViewById(R.id.send_pm_button);
        sendPm.setOnClickListener(PM.this);
        break;

    default:
        dialog = null;
   }