Solved

Android Development: Simple textbox with submit button

Posted on 2012-03-15
3
532 Views
Last Modified: 2012-03-15
I've created my textbox and my submit button on the main.xml.

I'm trying to store the textbox value (in this case, let's make it someone's name) after hitting the button to a string variable.

Whenever I try to create the entry though, it makes it an integer even though I'm finding it under R.string.someonesname

Any  help?
0
Comment
Question by:Dale Harris
  • 3
3 Comments
 
LVL 16

Author Comment

by:Dale Harris
Comment Utility
This is what I have so far:

        Button button = (Button) findViewById(R.id.button1);
    	button.setOnClickListener(new onClick() {
    		@Override
    	   public void onClick(View v) {
    	      // button 1 was clicked!

Open in new window


It's giving me a lot of errors in the way that I'm using it.  It can store the button, no problem, but when I try to set the onclicklistener, that's what it bombs out.

In my tests, I was able to set the textbox value, but the button is not being "clicked" to do anything.
0
 
LVL 16

Accepted Solution

by:
Dale Harris earned 0 total points
Comment Utility
I found the solution only 20 minutes later:

The import won't automatically find the right one, so you have to add:

import android.view.View.OnClickListener;

Then here's the exact working syntax:

        Button button = (Button) findViewById(R.id.button1);
          button.setOnClickListener(new OnClickListener()
          {
             public void onClick(View v)
                {
                // button 1 was clicked!
0
 
LVL 16

Author Closing Comment

by:Dale Harris
Comment Utility
This is harder than it looks people...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
If your app took Google’s lash recently, here are the 5 most likely reasons.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

772 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

11 Experts available now in Live!

Get 1:1 Help Now