انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
نحوه ساخت دکمه خروج و سوال هنگام خارج شدن از برنامه اندروید

نحوه ساخت دکمه خروج و سوال هنگام خارج شدن از برنامه اندروید

#7
کد زیر برای دکمه ای که در برنامه تان ساختید 

 
کد پی‌اچ‌پی:
    Button btnex=(ButtonfindViewById(R.id.button_exit);
        btnex.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick
(View arg0) {
        
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            
BuyPremiumActivity.this);

        
// set title
        
alertDialogBuilder.setTitle("خروج");

        
// set dialog message
        
alertDialogBuilder
            
.setMessage("از خرید منصرف شدید؟")
            .
setCancelable(false)
            .
setPositiveButton("بله",
            new 
DialogInterface.OnClickListener() {
                public 
void onClick(DialogInterface dialog,
                                    
int id) {
                    
// if this button is clicked, close
                    // current activity
                    
System.exit(id);
                }
            })
            .
setNegativeButton("ادامه میدهم",
            new 
DialogInterface.OnClickListener() {
                public 
void onClick(DialogInterface dialog,
                                    
int id) {
                    
dialog.cancel();
                }
            });

        
// create alert dialog
        
AlertDialog alertDialog alertDialogBuilder.create();

        
// show it
        
        
alertDialog.show();
        
        }



پاسخ
 سپاس شده توسط admin ، داش بهروز


پیام‌های این موضوع
RE: نحوه ساخت دکمه خروج و سوال هنگام خارج شدن از برنامه اندروید - توسط Erfannj - ۱۳۹۴/۰۷/۲۳, ۰۳:۳۸ ب.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان