Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OnClick Pop up new window to enter data

Posted on 2011-09-18
4
Medium Priority
?
509 Views
Last Modified: 2012-05-12
Hello,

I currently have a Edit Text on my Android app that I need to be able to click on and another pop up comes up so the user can enter data.

I have a toast box popup, but I would like a  popup so the user can enter the data and then the data gets sent back to the edit text.

The one I have below send the user to another activity. Please help

Thank you
myStockPrice.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// Click Text Box to Move to Next Activity
                Intent myIntent = new Intent(getApplicationContext(), StockQuoteLkup.class);
                startActivity(myIntent);
			}
		});

Open in new window

0
Comment
Question by:lulubell-b
  • 3
4 Comments
 
LVL 1

Expert Comment

by:Gyufa
ID: 36559399
Hi!

I created a sample app for you, i hope it helps!
dialog-test.zip
0
 

Author Comment

by:lulubell-b
ID: 36564589
Thank you, Perfect functionality, now I just have to implement into my application :)

I see the openDialogButton.setOnClickListener(new View.OnClickListener() which opens the dialog activity when clicked.

How do I do this when I click the edit text box?

myStockPrice = (EditText)findViewById(R.id.txtStockPrice);

        myStockPrice.setOnClickListener(new OnClickListener() {
                  @Override
            public void onClick(View view) {
                showDialog(DIALOG);
            }
            });



0
 

Accepted Solution

by:
lulubell-b earned 0 total points
ID: 36571314
I chose to imbed this code instead.

        // Click on Stock Price to bring up dialog box
        myStockPrice.setOnClickListener(new View.OnClickListener() {
                  
                  @Override
                  public void onClick(View v) {
                        // Click button to Move to Next Activity
                //Intent myIntent = new Intent(getApplicationContext(), StockQuoteLkup.class);
                //startActivity(myIntent);
               
                final AlertDialog.Builder alert = new AlertDialog.Builder(OptionsPricingCalculatorActivity.this);
                    final EditText input = new EditText(OptionsPricingCalculatorActivity.this);
                    alert.setView(input);
                    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int whichButton) {
                                String value = input.getText().toString().trim();
                                
                                //Toast.makeText(getApplicationContext(), value,
                                            //Toast.LENGTH_SHORT).show();
                          }
                    });

                    alert.setNegativeButton("Cancel",
                                new DialogInterface.OnClickListener() {
                                      public void onClick(DialogInterface dialog, int whichButton) {
                                            dialog.cancel();
                                      }
                                });
                    alert.show();
               
                  }
            });
0
 

Author Closing Comment

by:lulubell-b
ID: 36594802
This is more of what I was looking for.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Ransomware, the malware that locks down its victim’s files until they pay up, has always been a frustrating issue to deal with. However, a recent mobile ransomware will make the issue a little more personal… by sharing the victim’s mobile browsing h…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question