我的对话框代码为
public class ShowDialogScanFinger extends DialogFragment{
TextView t1;
ProgressBar p1;
@SuppressLint("NewApi")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
@SuppressWarnings("unused")
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = inflater.inflate(R.layout.scanyourfinger, container, false);
getDialog().requestWindowFeature(STYLE_NO_TITLE);
t1 = (TextView) view.findViewById(R.id.textViewScanFingerMessage);
p1 = (ProgressBar) view.findViewById(R.id.progressBarScanFinger);
p1.setVisibility(View.VISIBLE);
return view;
}
}
来自活动:
ShowDialogScanFinger dialogscanfinger;
dialogscanfinger = new ShowDialogScanFinger();
我将其称为
dialogscanfinger.show(getFragmentManager(), "scan");
如果我第一次打开对话框,但是如果想要第二次打开对话,那么每件事都没问题,那么我就会遇到问题......
在控制台我的应用程序崩溃和错误是
09-22 11:15:32.119: E/AndroidRuntime(9885): FATAL EXCEPTION: main
09-22 11:15:32.119: E/AndroidRuntime(9885): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
09-22 11:15:32.119: E/AndroidRuntime(9885): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
09-22 11:15:32.119: E/AndroidRuntime(9885): at java.util.ArrayList.set(ArrayList.java:477)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.app.FragmentManagerImpl.makeActive(FragmentManager.java:1078)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1103)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.app.BackStackRecord.run(BackStackRecord.java:569)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
09-22 11:15:32.119: E/AndroidRuntime(9885): android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.os.Handler.handleCallback(Handler.java:615)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.os.Handler.dispatchMessage(Handler.java:92)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.os.Looper.loop(Looper.java:153)
09-22 11:15:32.119: E/AndroidRuntime(9885): at android.app.ActivityThread.main(ActivityThread.java:4987)
09-22 11:15:32.119: E/AndroidRuntime(9885): at java.lang.reflect.Method.invokeNative(Native Method)
09-22 11:15:32.119: E/AndroidRuntime(9885): at java.lang.reflect.Method.invoke(Method.java:511)
09-22 11:15:32.119: E/AndroidRuntime(9885): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
09-22 11:15:32.119: E/AndroidRuntime(9885): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
09-22 11:15:32.119: E/AndroidRuntime(9885): at dalvik.system.NativeStart.main(Native Method)