?
Solved

Android Development: Simple textbox with submit button

Posted on 2012-03-15
3
Medium Priority
?
576 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The case of the missing phone talks about the way a small electronic gadget (the mobile phone) has penetrated into our lives and has made us addicted to it.
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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