Solved

OnClick Pop up new window to enter data

Posted on 2011-09-18
4
498 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
A short article about a problem I had getting the GPS LocationListener working.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

861 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now