Solved

Android Development: Simple textbox with submit button

Posted on 2012-03-15
3
561 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

827 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