2012-05-11 22 views
0

私はその電卓からダイアログボックス、そのcalculator.Onceユーザーが[OK]ボタンをクリックして、無料の問題/割引を計算しなければならない、フラグに依存するコンホメーションの変更ダイアログを表示する必要があります。アラートダイアログを表示するデザイン&までOKです。Androidのダイアログ内に警告ダイアログを表示しますか?

私の問題はダイアログの電卓が表示され、そこにOKをクリックすると警告ダイアログが表示され、警告結果ダイアログの結果はコードの結果となります。どうすればいいですか、一度アラートダイアログの結果を取得するだけで、残りの部分を行う必要があります。

これは私のコードです:

dialog = new Dialog(SalesActivityGroup.group.getParent()); 
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
View vLoad = LayoutInflater.from(SalesActivityGroup.group.getParent()).inflate(R.layout.key_pad, null); 
dialog.setContentView(vLoad);  
android.view.WindowManager.LayoutParams lp= dialog.getWindow().getAttributes(); 
lp.x = xVal; 
lp.y = yVal; 
lp.width = LayoutParams.WRAP_CONTENT; 
lp.height = LayoutParams.WRAP_CONTENT; 
lp.gravity = Gravity.TOP | Gravity.LEFT; 
lp.dimAmount = 0;    
dialog.getWindow().setAttributes(lp); 
dialog.setCancelable(false); 
keyamDisplay = (TextView)dialog.findViewById(R.id.keyamDisplay); 
TextView txtName = (TextView)dialog.findViewById(R.id.txtName); 
txtName.setText("Q"); 

Button txtDialogOK = (Button)dialog.findViewById(R.id.txtDialogOK); 
txtDialogOK.setOnClickListener(new OnClickListener() { 
public void onClick(View v) { 
    dialog.dismiss(); 
    popup = false; 
    try { 

      String productCode= txtCode.getText().toString(); 
      String number = txtNumber.getText().toString(); 
      int iVal = 0; //getting i value 
      if(number != "" && !number.equals("")){  
       iVal = Integer.parseInt(number); 
      }   
     String enteredQty = keyAmount.toString(); 
     String tmpEnterdPrice = txtPrice.getText().toString(); 
     double enterdPrice = Double.parseDouble(tmpEnterdPrice); 


    if(tmpQty > Double.parseDouble(stk.getText().toString())){ 
     if(disStockVali.equals("1")) { //Confirmation message if yes no discount , only entered <<Qty>> 
      AlertDialog.Builder disco = new AlertDialog.Builder(SalesActivityGroup.group.getParent()); 
      disco.setMessage("Discount Qty Not Enough!! \n Do you want to continue without discount ?"); 
      disco.setCancelable(false); 
      disco.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int id) { 
       dialog.dismiss(); 
       disStatus ="YES"; 
      } 
      }); 

      disco.setNegativeButton("No", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int id) { 
       dialog.cancel(); 
       disStatus ="NO"; 
       } 
      }); 
      disco.setTitle("Qty Not Enough"); 
      disco.show(); 
      System.out.println("==disStatus=="+disStatus); 

      if(disStatus.equals("YES")) { 
       System.out.println("==YES YES===="); 
       System.out.println("=YES=QTY==" + txtQty.getText().toString()); 
       disPro.setDiscountQty(0); 
       disPro.setDiscountProductCode(""); 
       disPro.setDiscountValue(0.00); 
      }else { 
       enteredQty = "0"; 
       txtQty.setText("0"); 
       valueInDouble = 0.00; 
       disPro.setDiscountQty(0); 
       disPro.setDiscountProductCode(""); 
       disPro.setDiscountValue(0.00); 
    } 
} 
    System.out.println("==2 QTY ==" +txtQty.getText().toString()); 
    System.out.println("==valueInDouble ==" +valueInDouble); 
    double tmpNet = valueInDouble - disPro.getDiscountValue(); 
    txtVal.setText(df.format(tmpNet)); 
    // TAX calculation 
    VatTax vatTax = calculateLineTax(productCode,Double.parseDouble(txtVal.getText().toString())); 

    }catch (Exception e) { 
    e.printStackTrace(); 
     } 
    dialog.dismiss(); 
} 
    }); 
    dialog.show();  

enter image description here

私を助けてください。

答えて

0

あなたはこれを期待していますか?ダイアログ内の警告ダイアログを表示し

public void Alert(String text, String title) 
    { 
     AlertDialog dialog=new AlertDialog.Builder(context).create(); 
     dialog.setTitle(title); 
     dialog.setMessage(text); 
     if(!title.equals("") && !text.equals("")) 
     { 
      dialog.setButton("OK", 
        new DialogInterface.OnClickListener() 
        { 
         public void onClick(DialogInterface dialog, int whichButton) 
         { 
          AlertDialog dg=new AlertDialog.Builder(context).create(); 
      dg.setTitle("OK Pressed"); 
      dg.show(); 
         } 
        }); 
      dialog.setButton2("Cancel", 
        new DialogInterface.OnClickListener() 
        { 
         public void onClick(DialogInterface dialog, int whichButton) 
         { 
          AlertDialog dg=new AlertDialog.Builder(context).create(); 
      dg.setTitle("Cancel Pressed"); 
      dg.show(); 
         } 
        }); 
     } 

     dialog.show(); 

    } 
+0

がwell.My要件がある表示され、ユーザー結果 – Piraba

+0

まで待機する必要がありますが、この確認でした:http://stackoverflow.com/questions/4381296/android-wait-on-userを-input-from-dialog – Ponmalar

関連する問題