Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8614839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:13:08+00:00 2026-06-12T05:13:08+00:00

I have designed an alertdialog of which when the user press the save button,

  • 0

I have designed an alertdialog of which when the user press the save button, it is hoped that it can return the user’s entered editTexts (the players’ scores) in the alert dialog back to the activity for further processing.

How could this be made? Would there be any samples? Many thanks!!

I have performed the below but the output now is it cannot recognize what is being input and ask user to input non-blank editText (goes through the else route at bottom):

public OnClickListener NewRowButtonListener = new OnClickListener()  
   {  
      @Override  
      public void onClick(View v)   
      {       
           AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);  

           dialog.setTitle("Add Scores"); //set title  
           View view = getLayoutInflater().inflate(R.layout.custom_dialog_add, null);  
           dialog.setView(view); 
           dialog.create();             
           final AlertDialog test = dialog.create();            
           SlotAlert_add_EditText = (EditText) view.findViewById(R.id.Slot_Alert_add_EditText); 
           P1Alert_add_ScoreEditText = (EditText) view.findViewById(R.id.P1_Alert_add_ScoreEditText); 
           P2Alert_add_ScoreEditText = (EditText) view.findViewById(R.id.P2_Alert_add_ScoreEditText); 
           P3Alert_add_ScoreEditText = (EditText) view.findViewById(R.id.P3_Alert_add_ScoreEditText); 
           P4Alert_add_ScoreEditText = (EditText) view.findViewById(R.id.P4_Alert_add_ScoreEditText);           

           Button alert_add_save = (Button) view.findViewById(R.id.Alert_add_SaveButton);  //find the Button object within the inflated view                                    
           alert_add_save.setOnClickListener(addButtonListener);        //set the onClickListener    
           test.show();     //show the dialog  
      } 
   }; 

and then

public OnClickListener addButtonListener = new OnClickListener() 
   // create a new Button and add it to the ScrollView    
   { 
      private String SlotAppend0EditText; 
      @Override 
      public void onClick(View v)  
      {            
            SlotEditText.setText(""+SlotAlert_add_EditText); //try to set EditText in MainActivity using the one in the alert dialog above 
            P1ScoreEditText.setText(""+P1Alert_add_ScoreEditText);  
            P2ScoreEditText.setText(""+P2Alert_add_ScoreEditText); 
            P3ScoreEditText.setText(""+P3Alert_add_ScoreEditText);  
            P4ScoreEditText.setText(""+P4Alert_add_ScoreEditText); 

         if (SlotEditText.getText().length() <4 && 
             SlotEditText.getText().length() > 0 && 
             P1ScoreEditText.getText().length() > 0 &&  
             P2ScoreEditText.getText().length() > 0 && 
             P3ScoreEditText.getText().length() > 0 &&  
             P4ScoreEditText.getText().length() > 0 )             
         { 
            SaveScoresToFile(SlotAppend0EditText, 
                    P1ScoreEditText.getText().toString(),  
                    P2ScoreEditText.getText().toString(),  
                    P3ScoreEditText.getText().toString(),  
                    P4ScoreEditText.getText().toString()); 
                         } // end if 
         else  (another alert message saying please enter valid input) //NOW THE RESULT IS SHOWING THIS! 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:13:10+00:00Added an answer on June 12, 2026 at 5:13 am

    see this

     Button b = (Button) findViewById(R.id.LeftMenu);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                 CreateAlertDialog ();
            }
        });
    

    Alert Dialog

     private void CreateAlertDialog () {         
    
        AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    
        alert.setTitle("Title");
        alert.setMessage("Message");
    
        // Set an EditText view to get user input 
        final EditText input = new EditText(getActivity());
        alert.setView(input);
    
        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
    
            }
        });
    
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
    
            }
        });
        alert.show();       
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed an online editor with which a user can create files and
I have designed a standalone application using swings which can read data from HID
I have designed a form where the user can enter his comment using Add
I have designed a webpage that can display properly in Windows XP (IE8) .
i have designed an form in that form contain button when i click on
I have designed an activity in which there is a listView. I want that
I have designed a website which has many JavaScript blocks: <script type='text/javascript'></script> Users can
I have designed a website in which I need to have access to user's
I have designed a database for an application which contains user settings. This database
I have designed a responsive layout that you can see here: http://pixelcakecreative.com/cimlife/responsive/ When viewed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.