Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Discussion > Android Applications

Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.



Reply
 
LinkBack Thread Tools
Old October 5th, 2010, 07:34 AM   #1 (permalink)
New Member
 
Join Date: Sep 2010
Posts: 2
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Android Application Problem

Check this class below,

______ My Code _______

public class Main extends Activity implements OnKeyListener {
DisplayWord currentWord;
TextView wordStatus;
EditText inputWord;
Button okBtn;
int pos = 1;
char currentChar;
char inputChar;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

currentWord = (DisplayWord) this.findViewById(R.id.trueWord);
currentWord.setText("Bonjure"); // word from database

wordStatus = (TextView) this.findViewById(R.id.wordStatus);

inputWord = (EditText) this.findViewById(R.id.wordInput);
inputWord.setOnKeyListener(this);
}

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (inputWord.getText().toString().length() <= currentWord.getText().toString().length()) {
pos = inputWord.getText().toString().length();
currentChar = currentWord.getText().toString().charAt(pos);
inputChar = inputWord.getText().toString().charAt(pos);

} return false;
}
}
_____ END _____

When running this code, upon entering data into the input box it causes an exception straight away and for the program exit unexpectedley.

I am trying to extract the input word from EditText field and the word stored in a TextView and to compare them char by char as those chars are entered into the input box, sort of a word game, where the character will be highlighted green if it is correct and red if it is not.

I have no idea why this behaviour happens, I can see in debugger an StringIndexOutOfBounds exception, and a ResourceNotFound when I have been tampering with different ways of attempting this.

Any advice or links appreciated,
Anthony

anthony.timotheou is offline  
Reply With Quote
Sponsors
Reply

Bookmarks

Tags
android problem


Go Back   Android Forums > Android Discussion > Android Applications User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Support Text problem: The application Messaging (process com.android.mms) has stopped unexpectedly. ev1ltw1n Samsung Galaxy S 16 February 26th, 2012 01:17 PM
Support Android market problem, application hold on starting download martani HTC Magic 41 February 15th, 2012 10:38 PM
Anybody Help me ! I got some Problem running android application using ANDROID_SAX trangdonkihote Application Development 0 March 12th, 2010 05:00 AM
Problem with Simple Audio Recorder Application : Android Jason_bill Android Media 1 May 28th, 2009 01:22 PM



All times are GMT -5. The time now is 10:43 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo