Solved

Android Development: Simple textbox with submit button

Posted on 2012-03-15
3
571 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 16

Author Comment

by:Dale Harris
ID: 37727415
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
ID: 37727457
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
ID: 37727460
This is harder than it looks people...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

These days software publishers make it possible to move all the possible applications on smartphones, tablets, smartwatches, and more. Although behind every logic and decision is a gross doubt: how do they make it possible? In this blog post, we sha…
There is a lot to be said for protecting yourself and your accounts with 2 factor authentication.  I found to my own chagrin, that there is a big downside as well.
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 tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

688 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