Solved

OnClick Pop up new window to enter data

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This video teaches viewers about errors in exception handling.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

14 Experts available now in Live!

Get 1:1 Help Now