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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:07:38+00:00 2026-06-08T16:07:38+00:00

Hi I’m an android newbie and I’ve been stuck for a week on this.

  • 0

Hi I’m an android newbie and I’ve been stuck for a week on this. Any help would be appreciated! I’ve done a lot of research and can’t figure out what is wrong. I’ve successfully run the bluetoothchat sample code on two phones and successfully communicated via bluetooth. I’ve also successfully written and run a standalone app that, after a button click on the main activity, opens a custom alertdialog which accepts user input, and passes the input back to the main activity. But when I write the alertdialog code into the BluetoothChat code, nothing happens when I click the button. I’ve tried to step through the debugger with the phone but with no luck. It doesn’t seem to step to the code containing the button click. There are no errors showing. Why won’t the alertdialog pop up on button click? Here’s the BluetoothChat.java code I’ve modified :

public class BluetoothChat extends Activity implements OnClickListener{

  final Context context = this;
  private Button rButton;
  View rScreen;
  private EditText mAlertDialog;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(D) Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.main);

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
      Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
      finish();
      return;
    }

    //components from main.xml
    //When button is clicked, the alert dialog is pulled up
    rButton = (Button)findViewById(R.id.buttonr);
    mAlertDialog = (EditText)findViewById(R.id.edittextresultm);

    //add button listener
    rButton.setOnClickListener(new OnClickListener() {

      //@Override
      public void onClick_register(View view) {   

        String title = "title";
        String buttonOk = "OK";
        String buttonCancel = "Cancel";
        String madd, name;

        //get review.xml view
        LayoutInflater li = LayoutInflater.from(context);
        View rView = li.inflate(R.layout.review, null);

        //AlertDialog dialog;   
        AlertDialog.Builder adRegister = new AlertDialog.Builder(context);


        //set review.xml to adRegister builder
        adRegister.setView(rView);

        //set title
        adRegister.setTitle(title);


        //Set EditText views to get user input

        final EditText mField = (EditText)rView.findViewById(R.id.editTextm);
        final EditText nField = (EditText)rView.findViewById(R.id.editTextn);

        //set dialog message
        adRegister.setMessage("Message")
          .setCancelable(false)
          .setPositiveButton(buttonOk, new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {

            String madd = mField.getText().toString();
            String name = nField.getText().toString();

            //get user input and set it to result on main activity
            mAlertDialog.setText(mField.getText());
          }
        })
        .setNegativeButton(buttonCancel, new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            //if this button is clicked, close current activity
            dialog.cancel();

          }
        });

        //Create alert dialog
        AlertDialog alertDialog = adRegister.create();
        //dialog= adRegister.create();
        //show it
        adRegister.show();
        //dialog.show();
      }

      public void onClick(View arg0) {
        // TODO Auto-generated method stub
      }
    });
  }
}
  • 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-08T16:07:46+00:00Added an answer on June 8, 2026 at 4:07 pm

    Write your inputDialog code in OnClick Method.

    Enjoy!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.