0

DB から行を削除するために func を呼び出すと、次のようになります。

public void deleteRow(int rowId) {
     getWritableDatabase().delete(DatabaseHelper.orderTable, "id="+rowId,null);

logcat に多くのエラー メッセージが表示されます。

06-02 16:32:14.356: E/WindowManager(2770): Activity com.Sagi.MyOrders.FindOrder has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f50540 that was originally added here
06-02 16:32:14.356: E/WindowManager(2770): android.view.WindowLeaked: Activity com.Sagi.MyOrders.FindOrder has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f50540 that was originally added here
06-02 16:32:14.356: E/WindowManager(2770):  at android.view.ViewRoot.<init>(ViewRoot.java:247)
06-02 16:32:14.356: E/WindowManager(2770):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
06-02 16:32:14.356: E/WindowManager(2770):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-02 16:32:14.356: E/WindowManager(2770):  at  android.view.Window$LocalWindowManager.addView(Window.java:424)
06-02 16:32:14.356: E/WindowManager(2770):  at android.app.Dialog.show(Dialog.java:241)
06-02 16:32:14.356: E/WindowManager(2770):  at com.Sagi.MyOrders.FindOrder.alert_editlist(FindOrder.java:56)
06-02 16:32:14.356: E/WindowManager(2770):  at com.Sagi.MyOrders.FindOrder.onItemLongClick(FindOrder.java:138)
06-02 16:32:14.356: E/WindowManager(2770):  at android.widget.AbsListView.performLongPress(AbsListView.java:1753)
06-02 16:32:14.356: E/WindowManager(2770):  at android.widget.AbsListView.access$600(AbsListView.java:72)
06-02 16:32:14.356: E/WindowManager(2770):  at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:1711)
06-02 16:32:14.356: E/WindowManager(2770):  at android.os.Handler.handleCallback(Handler.java:587)
06-02 16:32:14.356: E/WindowManager(2770):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-02 16:32:14.356: E/WindowManager(2770):  at android.os.Looper.loop(Looper.java:123)
06-02 16:32:14.356: E/WindowManager(2770):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-02 16:32:14.356: E/WindowManager(2770):  at java.lang.reflect.Method.invokeNative(Native Method)
06-02 16:32:14.356: E/WindowManager(2770):  at java.lang.reflect.Method.invoke(Method.java:521)
06-02 16:32:14.356: E/WindowManager(2770):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-02 16:32:14.356: E/WindowManager(2770):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-02 16:32:14.356: E/WindowManager(2770):  at dalvik.system.NativeStart.main(Native Method)

開いたままのカーソルまたはDBを探しましたが、何も見つかりませんでした。関数が戻った直後に、次のものがあります。

finish();

これが私のalertDialogクリエーターです:

private void alert_editlist(final int id) {
        // TODO Auto-generated method stub
        final CharSequence[] items = {"Edit", "Delete"};

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("What do you want to do?");
        builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                if (items[item]=="Edit") {
                }
                else if(items[item]=="Delete"){
                   finish();
                }
                finish();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }

ありがとうございます !!!

4

1 に答える 1

0

でダイアログを閉じますdismiss();

(delete メソッド呼び出しをその前に挿入する) に変更finish();するdismiss()と、より良い結果が得られるはずです。

于 2012-06-02T18:58:46.470 に答える