Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.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 程序因.onDialogPositiveClick而崩溃_Android_Crash_Dialog - Fatal编程技术网

Android 程序因.onDialogPositiveClick而崩溃

Android 程序因.onDialogPositiveClick而崩溃,android,crash,dialog,Android,Crash,Dialog,因此,目前我正在尝试将信息从对话框传递到主机活动,我已经完成了。但是,它在三个实例中崩溃: catch(ClassCastException e){ //活动未实现接口,引发异常 抛出新的ClassCastException(context.toString() +“必须实施通知式许可”); 委员会: mListener.onDialogPositiveClick(NDPickeris.this); 及 mListener.onDialogNegativeClick(NDPickeris.t

因此,目前我正在尝试将信息从对话框传递到主机活动,我已经完成了。但是,它在三个实例中崩溃:

catch(ClassCastException e){
//活动未实现接口,引发异常
抛出新的ClassCastException(context.toString()
+“必须实施通知式许可”);
委员会:

mListener.onDialogPositiveClick(NDPickeris.this);

mListener.onDialogNegativeClick(NDPickeris.this);
这是一项活动:

public类NDPickeris扩展了DialogFragment{
公共静态数组列表ndpam、allpam;
公共静态最终字符串MyPREFERENCES=“MyPrefs”;
/*公共静态最终数组列表ndpam=null*/
公共静态最终字符串Pi1=“nameKey11”,Pi2=“nameKey12”,Pi3=“nameKey13”,Pi4=“nameKey14”,
Pi5=“nameKey15”、Pi6=“nameKey16”、Pi7=“nameKey17”、Pi8=“nameKey18”、A1=“nameKey21”,
A2=“nameKey22”,A3=“nameKey23”,A4=“nameKey24”,A5=“nameKey25”,A6=“nameKey26”,
A7=“nameKey27”,A8=“nameKey28”,T1=“nameKey31”,T2=“nameKey32”,T3=“nameKey33”,
T4=“nameKey34”,T5=“nameKey35”,T6=“nameKey36”,T7=“nameKey37”,T8=“nameKey38”,
K1=“nameKey41”,K2=“nameKey42”,K3=“nameKey43”,K4=“nameKey44”,K5=“nameKey45”,
K6=“nameKey46”,K7=“nameKey47”,K8=“nameKey48”,Pe1=“nameKey51”,Pe2=“nameKey52”,
Pe3=“nameKey53”、Pe4=“nameKey54”、Pe5=“nameKey55”、Pe6=“nameKey56”、Pe7=“nameKey57”,
Pe8=“nameKey58”;
SharedReferences SharedReferences;
/*创建此对话框片段实例的活动必须
*实现此接口以接收事件回调。
*每个方法都传递DialogFragment,以防主机需要查询它*/
公共界面通知灯{
void onDialogPositiveClick(对话框片段对话框);
void onDialogNegativeClick(对话框片段对话框);
}
//使用此接口实例传递操作事件
注意英语学习者;
//重写Fragment.onAttach()方法以实例化NoticeDialogListener
@凌驾
公共void-onAttach(上下文){
super.onAttach(上下文);
//验证主机活动是否实现了回调接口
试一试{
//实例化NoticeDialogListener,以便我们可以向主机发送事件
mListener=(noticediaglistener)上下文;
}catch(ClassCastException e){
//活动未实现接口,引发异常
抛出新的ClassCastException(context.toString()
+“必须实施通知式许可”);
}
}
创建对话框上的公共对话框(Bundle savedInstanceState){
AlertDialog.Builder=新建AlertDialog.Builder(getActivity());
//找到布局充气机
LayoutFlater充气机=getActivity().GetLayoutFlater();
最终视图=充气机充气(R.layout.nd_pickeris,空);
最终旋转器旋转;
spin=(微调器)view.findViewById(R.id.pamoka_微调器);
SharedReferences=getActivity().GetSharedReferences(MyPREFERENCES,Context.MODE\u PRIVATE);
ndpam=newarraylist();
allpam=newarraylist();
allpam.add(SharedReferences.getString(Pi1,“”));
allpam.add(SharedReferences.getString(Pi2,“”));
allpam.add(SharedReferences.getString(Pi3,“”));
allpam.add(SharedReferences.getString(Pi4,“”));
allpam.add(SharedReferences.getString(Pi5,“”));
allpam.add(SharedReferences.getString(Pi6,“”));
allpam.add(sharedReferences.getString(Pi7,“”);
allpam.add(SharedReferences.getString(Pi8,“”);
allpam.add(SharedReferences.getString(A1,“”));
allpam.add(SharedReferences.getString(A2,“”));
allpam.add(SharedReferences.getString(A3,“”);
allpam.add(SharedReferences.getString(A4,“”);
allpam.add(SharedReferences.getString(A5,“”);
allpam.add(SharedReferences.getString(A6,“”);
allpam.add(sharedReferences.getString(A7,“”);
allpam.add(SharedReferences.getString(A8,“”));
allpam.add(sharedReferences.getString(T1,“”);
allpam.add(sharedReferences.getString(T2,“”);
allpam.add(sharedReferences.getString(T3,“”);
allpam.add(SharedReferences.getString(T4,“”);
allpam.add(SharedReferences.getString(T5,“”);
allpam.add(SharedReferences.getString(T6,“”);
allpam.add(sharedReferences.getString(T7,“”));
allpam.add(sharedReferences.getString(T8,“”));
allpam.add(SharedReferences.getString(K1,“”));
allpam.add(SharedReferences.getString(K2,“”);
allpam.add(SharedReferences.getString(K3,“”));
allpam.add(sharedReferences.getString(K4,“”);
allpam.add(SharedReferences.getString(K5,“”);
allpam.add(sharedReferences.getString(K6,“”);
allpam.add(sharedReferences.getString(K7,“”);
allpam.add(SharedReferences.getString(K8,“”));
allpam.add(SharedReferences.getString(Pe1,“”));
allpam.add(SharedReferences.getString(Pe2,“”));
allpam.add(SharedReferences.getString(Pe3,“”));
allpam.add(SharedReferences.getString(Pe4,“”));
allpam.add(SharedReferences.getString(Pe5,“”));
allpam.add(SharedReferences.getString(Pe6,“”));
allpam.add(SharedReferences.getString(Pe7,“”));
allpam.add(SharedReferences.getString(Pe8,“”);
for(int i=0;ibtn.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v) {
        NDPickeris fr = new NDPickeris();
        // reference of your interface NoticeDialogListener
        fr.setListener(this);
        fr.show(getFragmentManager(), "");
    }
});
 // setter method on your dialog fragment
 public void setListener(NoticeDialogListener mListener) {
      // now u set value on your listener
      this.mListener = mListener;
 }
// Verify that the host activity implements the callback interface
    try {
        // Instantiate the NoticeDialogListener so we can send events to the host
        mListener = (NoticeDialogListener) context;
    } catch (ClassCastException e) {
        // The activity doesn't implement the interface, throw exception
        throw new ClassCastException(context.toString()
                + " must implement NoticeDialogListener");
    }