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

  • SEARCH
  • Home
  • 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 6606493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:24:06+00:00 2026-05-25T19:24:06+00:00

Right now I can only see the fetched values when I press OK button

  • 0

Right now I can only see the fetched values when I press OK button of the dialog. But I want to see it when the alertdialog appears. I know I have put the display code inside the .setPositiveButton(“OK”, But even when I tried putting it before that, it didnt work. I some how have idea that i need to make use of this setview(addView) but dont know how. Please help me.

enter code here
private void populateFields() {
    LayoutInflater inflater=LayoutInflater.from(this);
    final View addView=inflater.inflate(R.layout.add_country, null);

    new AlertDialog.Builder(this)
    .setTitle("Edit country/year")
    .setView(addView)
    .setPositiveButton("OK", 
    new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog,int whichButton) {
    Cursor c = 
         getContentResolver().query                                                                   (CONTENT_URI.buildUpon                                             ().appendPath(String.valueOf(mRowId)).build(), null, null, null, null);
    /* Read alert input */
    EditText editCountry =(EditText)addView.findViewById(R.id.editCountry);
    EditText editYear =(EditText)addView.findViewById(R.id.editYear);
    //System.out.println(c.getString(c.getColumnIndex("country")));
    editCountry.setText(c.getString(c.getColumnIndex("country")));
    editYear.setText(c.getString(c.getColumnIndex("year")));
                }
                })
    .setNegativeButton("Cancel",
        new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog,int whichButton) {
      // ignore, just dismiss
    }
})
    .show();
}
  • 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-05-25T19:24:07+00:00Added an answer on May 25, 2026 at 7:24 pm

    Try putting your code right after you have inflated the view. Something like this :

    private void populateFields() {
    LayoutInflater inflater=LayoutInflater.from(this);
    final View addView=inflater.inflate(R.layout.add_country, null);
    
    Cursor c = getContentResolver().query(CONTENT_URI.buildUpon().appendPath(String.valueOf(mRowId)).build(), null, null, null, null);
    /* Read alert input */
    EditText editCountry =(EditText)addView.findViewById(R.id.editCountry);
    EditText editYear =(EditText)addView.findViewById(R.id.editYear);
    
    editCountry.setText(c.getString(c.getColumnIndex("country")));
    editYear.setText(c.getString(c.getColumnIndex("year")));
    
    new AlertDialog.Builder(this)
    .setTitle("Edit country/year")
    .setView(addView)
    .setPositiveButton("OK",null)
    .setNegativeButton("Cancel",null)
    .show();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an app that's in invite-only beta right now. Problem is, I can't
I can't seem to see the forest for the trees right now (Looked at
I wish so the users can only send to their friends. Right now I
Right now I can use this URL to request a Google Static Maps image
How do you install Boost on MacOS? Right now I can't find bjam for
Background: I have a kubuntu laptop right now that I can't use wirelessly, i.e.
I'm pretty much at wits end right about now and can't seem to figure
I'm learning Ruby right now and I got stuck, maybe you guys can help
How can I validate the user input by using scanf. Right now I have
How can i make sure that several divs are slided up? Right now I

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.