Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 09-23-2008, 06:13 AM   #1
Junior Member
 
Join Date: Sep 2008
Posts: 2
Friends: 0
View Wuque's Profile   View Wuque's Photo Album   View Wuque's Blog   View Social Groups
Hi you all! I'd like to know how to read the inputs from the keyboard on Android. In java i use:


InputStreamReader reader = new InputStreamReader (System.in);
BufferedReader myInput = new BufferedReader (reader);
String str= new String();
str = myInput.readLine();


... but how in Android?

Thanks
Wuque is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 10-26-2008, 12:12 PM   #2
Junior Member
 
Join Date: Oct 2008
Posts: 10
Friends: 0
View abisong's Profile   View abisong's Photo Album   View abisong's Blog   View Social Groups
Quote:
Originally Posted by Wuque View Post
Hi you all! I'd like to know how to read the inputs from the keyboard on Android. In java i use:


InputStreamReader reader = new InputStreamReader (System.in);
BufferedReader myInput = new BufferedReader (reader);
String str= new String();
str = myInput.readLine();


... but how in Android?

Thanks

Have you looked at this packages:

java.io Provides input and output facilities by means of streaming, filesystem access and serialization.
java.lang Provides core classes of the Android environment.

Go to http://code.google.com/android/reference/packages.html for all android API's

Anthony Bisong
jpWireless Technologies
abisong is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 06-09-2009, 01:40 PM   #3
Junior Member
 
Join Date: Jun 2009
Posts: 3
Friends: 0
View The_Rick_14's Profile   View The_Rick_14's Photo Album   View The_Rick_14's Blog   View Social Groups
The best way I've seen to this point is to use an EditText object which has a call to getText() that you can make to get what is currently in the corresponding text box.

I generally create the EditText view in the xml file. Be sure to give it an id by using:

android:id="@+id/your_id_here"

Then in the java...above onCreate() you should initialize the object so that you can access it throughout the file. Then within on create you'll want to do the following:

editTextView = (EditText) findViewById(R.id.your_id_here);

Then you should be able at any time to call editTextView.getText()
The_Rick_14 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 08-28-2011, 03:18 PM   #4
New Member
 
Join Date: Aug 2011
Posts: 11
Friends: 0
View Obfuscation's Profile   View Obfuscation's Photo Album   View Obfuscation's Blog   View Social Groups
I am having a problem with a simple pay check calculator.

I have an EditText for hours worked, and one for hourly wages. However, I'm lost when it comes to snagging the input from those EditTexts. I have tried the editText.getText() method, but when I add that to say total = editText.getText() I get an error saying type conversion of Editable to double is not allowed.

Sorry if this is the wrong place to post this. I have tried several searches and this one seemed to be the best place from what the search yielded.

Thanks in andvance

Obfuscation
Obfuscation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 08-29-2011, 09:14 AM   #5
New Member
 
Join Date: Aug 2011
Posts: 11
Friends: 0
View Obfuscation's Profile   View Obfuscation's Photo Album   View Obfuscation's Blog   View Social Groups
Just thought I would post this in case someone reads through this and is having a similar problem.

I have corrected the problem, although I have ran into a new one, but it was fixed by:

1st of all, the data types I'm working with are float

2nd I changed the declaration of my variables to be:

Float.parseFloat(editText.getText().toString());
Obfuscation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 08-31-2011, 06:42 AM   #6
New Member
 
Join Date: Aug 2011
Posts: 22
Friends: 0
View sjums's Profile   View sjums's Photo Album   View sjums's Blog   View Social Groups
Quote:
Originally Posted by Obfuscation View Post
Just thought I would post this in case someone reads through this and is having a similar problem.

I have corrected the problem, although I have ran into a new one, but it was fixed by:

1st of all, the data types I'm working with are float

2nd I changed the declaration of my variables to be:

Float.parseFloat(editText.getText().toString());
And the new problem is?
sjums is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 09-04-2011, 11:32 AM   #7
New Member
 
Join Date: Aug 2011
Posts: 11
Friends: 0
View Obfuscation's Profile   View Obfuscation's Photo Album   View Obfuscation's Blog   View Social Groups
Wow, didn't think anyone was using this Forum anymore. Thanks for posting.

Anywhere that I have changed the variable declaration of say:

float myFloat = Float.parseFloat(editText.getText().toString());

Causes the app to crash. I can't figure out how to get by this. I have changed the parseFloat() to valueOf() and it still does the same thing. I dunno if I'm using the right things to solve the problem. I only want to perform a simple calculation based upon input from the user.
Obfuscation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 09-04-2011, 10:30 PM   #8
New Member
 
Join Date: Aug 2011
Posts: 22
Friends: 0
View sjums's Profile   View sjums's Photo Album   View sjums's Blog   View Social Groups
I am active, not the forum :b

I guess you get an inputformatexception or something in that direction?

If yes, what's in that txtBox.?
sjums is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 09-05-2011, 09:11 AM   #9
New Member
 
Join Date: Aug 2011
Posts: 11
Friends: 0
View Obfuscation's Profile   View Obfuscation's Photo Album   View Obfuscation's Blog   View Social Groups
Well to be honest I haven't really sat down and tried using the Debugger that comes with Eclipse. All I get is an un-expected error, but to answer your question when I test the application I use float integers 8.0, 7.0, etc.
Obfuscation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 09-05-2011, 11:30 AM   #10
New Member
 
Join Date: Aug 2011
Posts: 11
Friends: 0
View Obfuscation's Profile   View Obfuscation's Photo Album   View Obfuscation's Blog   View Social Groups
To be brutaly honest, I have no clue on how to view any of the error messages that may be thrown out. I just get the dreaded box at application startup saying that there was an unexpected error and the application has quit. Then ensues the force close and wondering where I went wrong.
Obfuscation is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Forum Rules Please Read! Andor Site Feedback 0 05-23-2008 07:10 AM
New to Android? Read the FAQ Andor Introduce Yourself 0 03-13-2008 08:39 AM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 04:15 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.