2016-03-26 29 views
1

Androidで行える一連のダイアログメニューを作成して、AndroidでUSSDのやり取りを模擬しようとしています。ダイアログの間に「USSD code running ...」と表示される進捗ダイアログが表示されるようにしていますが、ポジティブボタンをクリックすると、実行可能なタイマーでProgressDialogを実行してそれに従おうとするとFirstTimeUserと呼ばれる次のダイアログでは、他のタイマーと分離しようとしても、レイヤーを別のレイヤーの上にレイヤーするだけです。どのように私はそれらを同時にではなく連続して動かすことができますか?以下のコードスニペット:ダイアログ間で進捗状況を表示

USSDprogressDialog(); 
    AlertDialog.Builder builder = new AlertDialog.Builder(this); 
    LayoutInflater inflater = this.getLayoutInflater(); 

    // Inflate and set the layout for the dialog 
    // Pass null as the parent view because its going in the dialog layout 
    final View dialogView = inflater.inflate(R.layout.number_response_dialog, null); 
    builder.setView(dialogView) 
      .setMessage(R.string.MainMenuText) 
      // Add action buttons 
      .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int id) { 
        // Send number to next dialog 
        String choice = getMenuChoice(dialogView); 
        if (choice.equals("5")) { 
         USSDprogressDialog(); 
         FirstTimeUse(); 
        } else { 
         //Do nothing 
        } 
       } 
      }) 
      .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int id) { 
        // End session 
       } 
      }); 
    AlertDialog dialog = builder.create(); 
    dialog.show(); 

、タイマーで進捗ダイアログは、次のとおりです。

public void USSDprogressDialog() { 
    final ProgressDialog progress = new ProgressDialog(this); 
    progress.setMessage("USSD code running..."); 
    progress.show(); 


    Runnable progressRunnable = new Runnable() { 

     @Override 
     public void run() { 
      progress.cancel(); 
     } 
    }; 

    Handler handler = new Handler(); 
    handler.postDelayed(progressRunnable, 2000); 
} 

任意の提案は歓迎されるでしょう!ありがとうございました!

答えて

1

FirstTimeUse()をダイアログのprogressCancelに移動します。多分USSDprogressDialog(Runnable runnable)を作成する必要があります

+0

提案したようにprogressClanにFirstTimeUseを含めてみました。しかし今、別の問題があります。これは、USSDProgressDialogジェネリックをすべてのダイアログ間に含めることができるようにする必要があることです。多くのダイアログがあります。私はそれに取り組んでいます。ありがとうございました!! – notchopra

+0

2番目の文を見てください - USSDprogressDialogに実行可能ファイルを受けさせてください –

+0

ああ!私はあなたが今何を意味しているかを見ます。ありがとうございました!! – notchopra

関連する問題