Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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 DialogFragment中的InvocationTargetException&;数学家_Android_Android Alertdialog_Android Dialogfragment_Android Inflate_Numberpicker - Fatal编程技术网

Android DialogFragment中的InvocationTargetException&;数学家

Android DialogFragment中的InvocationTargetException&;数学家,android,android-alertdialog,android-dialogfragment,android-inflate,numberpicker,Android,Android Alertdialog,Android Dialogfragment,Android Inflate,Numberpicker,我试图在对话框中显示NumberPicker,以便让用户选择0到10之间的值。这是我花了第二天的时间让它工作 这就是我所拥有的: 碎片编号选择器(布局): 来自主活动的呼叫: public void openNumberPicker(){ FragmentManager fm = getSupportFragmentManager(); NumberPickerCustomDialog npc = new NumberPickerCustomDialog();

我试图在对话框中显示NumberPicker,以便让用户选择0到10之间的值。这是我花了第二天的时间让它工作

这就是我所拥有的:

  • 碎片编号选择器(布局):

  • 来自主活动的呼叫:

    public void openNumberPicker(){
         FragmentManager fm = getSupportFragmentManager();
         NumberPickerCustomDialog npc = new NumberPickerCustomDialog();
         npc.show(fm, "fragment_number_picker");
    }
    
我收到一个InvocationTargetException,但我无法使它工作


有什么想法吗?谢谢

尝试更改您正在使用的上下文:

context = getActivity().getApplicationContext();
相反,您需要活动自己的上下文:

context = getActivity();
context = getActivity().getApplicationContext();
context = getActivity();