如题我在ACTIVITY调用自定义的VIEW
在VIEW中的屏幕触发事件里面会显示这个对话框,
第一次点击时,对话框弹出正常,对话框输入的值也可以取到,
但是关掉后,第二次点击就会出错,我看异常为IllegleStateException
如果注掉这个对话框(.setView(edt)),第二次点击就没有问题,
请各位高手帮助解决!!public class GameView2 extends View { final PopupWindow popupWindow;
AlertDialog.Builder bombNumSetWindow;
EditText edt; public GameView2(Context context) {
super(context);
bombNumSetWindow=new AlertDialog.Builder(context) ;
bombNumSetWindow
.setTitle("请输入")
.setIcon(android.R.drawable.ic_dialog_info)
.setView(edt)
.setPositiveButton("确定", null)
.setNegativeButton("取消", null);
//.setPositiveButton("确定", edtOKClickListener)
//.setNegativeButton("取消", edtCancelClickListener); .....
} public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
int ax = (int) event.getX();
int ay = (int) event.getY(); if (event.getAction() == MotionEvent.ACTION_DOWN) { .....
bombNumSetWindow.show();
.....
}
} ..... // 确定按钮消息处理
DialogInterface.OnClickListener edtOKClickListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
xxx=edt.getText().toString();
showOkInfo(xxx);
}
};
// 取消按钮消息处理
DialogInterface.OnClickListener edtCancelClickListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
//xxx=edt.getText().toString();
//showOkInfo(xxx);
}
};};
在VIEW中的屏幕触发事件里面会显示这个对话框,
第一次点击时,对话框弹出正常,对话框输入的值也可以取到,
但是关掉后,第二次点击就会出错,我看异常为IllegleStateException
如果注掉这个对话框(.setView(edt)),第二次点击就没有问题,
请各位高手帮助解决!!public class GameView2 extends View { final PopupWindow popupWindow;
AlertDialog.Builder bombNumSetWindow;
EditText edt; public GameView2(Context context) {
super(context);
bombNumSetWindow=new AlertDialog.Builder(context) ;
bombNumSetWindow
.setTitle("请输入")
.setIcon(android.R.drawable.ic_dialog_info)
.setView(edt)
.setPositiveButton("确定", null)
.setNegativeButton("取消", null);
//.setPositiveButton("确定", edtOKClickListener)
//.setNegativeButton("取消", edtCancelClickListener); .....
} public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
int ax = (int) event.getX();
int ay = (int) event.getY(); if (event.getAction() == MotionEvent.ACTION_DOWN) { .....
bombNumSetWindow.show();
.....
}
} ..... // 确定按钮消息处理
DialogInterface.OnClickListener edtOKClickListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
xxx=edt.getText().toString();
showOkInfo(xxx);
}
};
// 取消按钮消息处理
DialogInterface.OnClickListener edtCancelClickListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
//xxx=edt.getText().toString();
//showOkInfo(xxx);
}
};};
解决方案 »
- 关于popupwindow很神奇的问题
- Windows下,Cocos2d-x学习之创建Android工程和编译:编译刚创建的testandroid项目出错
- Android人人网客户端实现思路?
- No Launcher activity found
- Android中Adapter,获取position的原理是什么呢?
- 高手请进(高分重赏,不够另开贴加分)
- 在网上Download了一个android通讯录,总是出错,请高手指点一下
- 关于APP请求Root权限,在代码中的实现?
- 刚学安卓开发,哪位能给我发下安卓的官方例子,这里墙的上不去谷歌官网,开发环境是android studio
- Android studio 定位应用
- handlemessage 使用SimpleAdapter 报错
- 谁帮我看看这个错误咋决解?
不好意思忘记COPY构造函数的这句了
edt=new EditText(context);
未能打开编辑器:Unmatched braces in the pattern.
这个右边的“详细信息"按钮点开后有下面这些内容,不知道是不是出错信息。java.lang.IllegalArgumentException: Unmatched braces in the pattern.
at java.text.MessageFormat.applyPattern(MessageFormat.java:508)
at java.text.MessageFormat.<init>(MessageFormat.java:363)
at java.text.MessageFormat.format(MessageFormat.java:835)
at org.eclipse.jdt.internal.core.util.Messages.bind(Messages.java:393)
at org.eclipse.jdt.internal.core.util.Messages.bind(Messages.java:359)
at org.eclipse.jdt.internal.core.util.Disassembler.disassemble(Disassembler.java:923)
at org.eclipse.jdt.internal.core.util.Disassembler.disassemble(Disassembler.java:282)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$SourceAttachmentForm.updateCodeView(ClassFileEditor.java:407)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$SourceAttachmentForm.createControl(ClassFileEditor.java:210)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.verifyInput(ClassFileEditor.java:770)
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.createPartControl(ClassFileEditor.java:720)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:662)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:286)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2857)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility$1.run(SourceLookupFacility.java:352)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility.openEditor(SourceLookupFacility.java:362)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility.openEditor(SourceLookupFacility.java:287)
at org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility.display(SourceLookupFacility.java:219)
at org.eclipse.debug.ui.DebugUITools.displaySource(DebugUITools.java:792)
at org.eclipse.debug.internal.ui.elements.adapters.StackFrameSourceDisplayAdapter$SourceDisplayJob.runInUIThread(StackFrameSourceDisplayAdapter.java:155)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3506)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)