私はカスタムAlertDialogを作成するために使用しているコードです。AlertDialog強制終了
public void onButtonClicked(View v) {
LayoutInflater onButtonClick = LayoutInflater.from(this);
PropManager propmanager = new PropManager();
final View onButtonClickView = onButtonClick.inflate(
R.layout.buttondialog, null);
TextView mbname = (TextView) findViewById(R.id.mbname);
TextView mbdisplayid = (TextView) findViewById(R.id.mbdisplayid);
TextView mbdevice = (TextView) findViewById(R.id.mbdevice);
TextView mbkernel = (TextView) findViewById(R.id.mbkernel);
TextView mbvspath = (TextView) findViewById(R.id.mbvspath);
String mbvspathv = propmanager.multiBootVSPathProp();
String mbkernelv = propmanager.kernelProp();
String mbdevidev = propmanager.deviceProp();
String mdisplayidv = propmanager.displayIdProp();
String mbnanev = propmanager.vSNameProp();
mbname.setText(mbnanev);
mbdisplayid.setText(mdisplayidv);
mbdevice.setText(mbdevidev);
mbkernel.setText(mbkernelv);
mbvspath.setText(mbvspathv);
new AlertDialog.Builder(this).setView(onButtonClickView).show();
}
public String vSNameProp() {
String mbvsprop = "none";
try {
Scanner scanner = new Scanner(propReader()).useDelimiter("\\n");
scanner.findWithinHorizon(
Pattern.compile("\\[ro.multiboot.vs\\].*\\[(.+?)\\]"), 0);
mbvsprop = scanner.match().group(1);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File vs = new File(mbvsprop);
return "Active VFS\t: " + vs.getName();
}
しかし、ボタンをクリックすると強制的に閉じます。
03-30 17:01:59.717: W/System.err(9802): java.lang.IllegalStateException
03-30 17:01:59.727: W/System.err(9802): at java.util.Scanner.match(Scanner.java:963)
03-30 17:01:59.727: W/System.err(9802): at com.manager.boot.free.PropManager.vSNameProp(PropManager.java:138)
03-30 17:01:59.737: W/System.err(9802): at com.manager.boot.free.OSListActivity.onButtonClicked(OSListActivity.java:1177)
03-30 17:01:59.737: W/System.err(9802): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 17:01:59.737: W/System.err(9802): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 17:01:59.737: W/System.err(9802): at android.view.View$1.onClick(View.java:3039)
03-30 17:01:59.737: W/System.err(9802): at android.view.View.performClick(View.java:3511)
03-30 17:01:59.737: W/System.err(9802): at android.view.View$PerformClick.run(View.java:14105)
03-30 17:01:59.737: W/System.err(9802): at android.os.Handler.handleCallback(Handler.java:605)
03-30 17:01:59.737: W/System.err(9802): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 17:01:59.747: W/System.err(9802): at android.os.Looper.loop(Looper.java:137)
03-30 17:01:59.757: W/System.err(9802): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-30 17:01:59.757: W/System.err(9802): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 17:01:59.767: W/System.err(9802): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 17:01:59.767: W/System.err(9802): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-30 17:01:59.767: W/System.err(9802): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-30 17:01:59.767: W/System.err(9802): at dalvik.system.NativeStart.main(Native Method)
03-30 17:01:59.767: D/AndroidRuntime(9802): Shutting down VM
03-30 17:01:59.767: W/dalvikvm(9802): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
03-30 17:01:59.787: E/AndroidRuntime(9802): FATAL EXCEPTION: main
03-30 17:01:59.787: E/AndroidRuntime(9802): java.lang.IllegalStateException: Could not execute method of the activity
03-30 17:01:59.787: E/AndroidRuntime(9802): at android.view.View$1.onClick(View.java:3044)
03-30 17:01:59.787: E/AndroidRuntime(9802): at android.view.View.performClick(View.java:3511)
03-30 17:01:59.787: E/AndroidRuntime(9802): at android.view.View$PerformClick.run(View.java:14105
)
なぜ?
これはalertdialogの問題でした。 'TextView mbname =(TextView)onButtonClickView.findViewById(R.id.mbname);'を使用しています。 –