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 8738115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:40:29+00:00 2026-06-13T10:40:29+00:00

I am trying to make a dialog that basically asks for the genre of

  • 0

I am trying to make a dialog that basically asks for the genre of the song from the user.
Thus I have two buttons and an EditText. I want to fetch the string from EditText when I hit the “Save” button and save it to the database. but the problem is the EditText is returning and empty string which can be due to the fact that I just can’t relate the Edittext to the one in the layout. Code Snippet:

class AskGenreDialog {
        private String songTitle = "";
        private int id;
        EditText AskGenre;
        View view;
        public void setSongTitle(String songTitle){
            this.songTitle = songTitle;
        }

        public void setId(int id){
            this.id = id;
        }
        public void onCreateDialog(){

            AlertDialog.Builder builder = new AlertDialog.Builder(MusicPlayerActivity.this);
            LayoutInflater inflator = (LayoutInflater)MusicPlayerActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            builder.setView(inflator.inflate(R.layout.ask_genre, null));
            builder.setTitle("Genre Not Found").setMessage(songTitle);
            view = inflator.inflate(R.layout.ask_genre, null);
            AskGenre = (EditText) view.findViewById(R.id.genre);

            builder.setPositiveButton("Save", new OnClickListener(){

                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    // TODO Auto-generated method stub
                    String genre =AskGenre.getText().toString();
                    handler.setGenreForId(genre,id);
                    Log.d("Ans:", genre);
                }

            });
            builder.setNegativeButton("Don't Know", new OnClickListener(){

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }

            });

            // create alert dialog
            AlertDialog alertDialog = builder.create();

            // show it
            alertDialog.show();
        }

    }

Can anyone tell me the problem please?

  • 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-13T10:40:30+00:00Added an answer on June 13, 2026 at 10:40 am

    in the view= line, you create another instance than the one used in the dialog.

    Do this instead

    view = inflator.inflate(R.layout.ask_genre, null);
    builder.setView(view);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a Dialog that has an EditText on it where
I'm trying to make a Mac OS X application that asks the user for
I am trying to make a semi-transparent Dialog so that you can see the
I am trying to make it so that when a user clicks a button,
I'm trying to make it so that a dialog pops up for users which
I have been trying to make my Alert Dialog with rounded corners but somehow
I'm trying to create a dialog that uses two GUI elements: KDEUI KActionSelector and
I am trying to make a dialog button that pops up when i am
I have a pop up dialog box and I am trying to make it
I'm trying to use a Swing Dialog so that the user can choose an

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.