• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps IndexOutOfBoundsException when moving through EditBoxess

Leolicos

Member
I have 6 EditBoxes (2 columns and 3 rows), when I click on one of them and move through them with the track ball, it focuses on the correct one appropriately; but when I keep moving down, past the last row, it gives me that exception. How do I tell it, when it's focused at the bottom and the trackball is moved downwards, don't try to focus on anything below (since there isn't anything below it)
 
Hi Leolicos

I think you'll need to supply more info before anyone can offer much help.
Can you post the exception and stack trace from the log, along with the code the exception relates to.

Mark

p.s. Please use CODE tags when posting code. (Just in case you weren't aware of them.)
 
There really isn't any code... it has to do with my layout. I know this because I started a new application (basically the Hello, Android app) and put my layout with nothing implemented and it still crashes.

The exception.

Thread [<3> main] (Suspended (exception IndexOutOfBoundsException))
ViewRoot.draw(boolean) line: 1356
ViewRoot.performTraversals() line: 1097
ViewRoot.handleMessage(Message) line: 1613
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4203
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 791
ZygoteInit.main(String[]) line: 549
NativeStart.main(String[]) line: not available [native method]
 
Code:
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
	xmlns:android="http://schemas.android.com/apk/res/android" 
	android:layout_width="fill_parent" 
	android:layout_height="fill_parent">
	
	<RelativeLayout
		android:layout_width="fill_parent" 
		android:layout_height="wrap_content">
	   	<ImageView
	   		android:id="@+id/background"
	   		android:layout_width="wrap_content"
	   		android:layout_height="wrap_content"
	   		android:scaleType="fitXY"
	   		android:src="@drawable/back_v" />
	   	<ImageView
	   		android:id="@+id/image"
	   		android:paddingTop="25px"
	   		android:layout_width="fill_parent"
	   		android:layout_height="wrap_content"
	   		android:src="@drawable/right" />
		<RelativeLayout
			android:layout_width="fill_parent" 
			android:layout_height="wrap_content"
			android:gravity="right"
			android:paddingRight="2px"
			android:paddingTop="5px">
			<Button
				android:id="@+id/how"
				android:text="Show The Work!"
				android:enabled="false"
				android:layout_width="wrap_content"
		        android:layout_height="wrap_content" />
		</RelativeLayout>
	</RelativeLayout>
   		
	<LinearLayout
		android:layout_width="fill_parent" 
		android:layout_height="wrap_content"
		android:orientation="vertical"
		android:paddingTop="220px"
		android:paddingRight="4px"
		android:paddingLeft="5px" >
		<LinearLayout
			android:layout_width="fill_parent" 
			android:layout_height="wrap_content"
			android:orientation="horizontal">
			<LinearLayout
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"
				android:orientation="horizontal" >
				<TextView 
					android:id="@+id/lblRounding"
					android:textColor="#000000"
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:text="Length " />
				<TextView 
					android:id="@+id/rounding"
					android:textColor="#000000"
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:text="()" />
			</LinearLayout>
			<LinearLayout
				android:layout_width="fill_parent" 
				android:layout_height="wrap_content"
				android:orientation="horizontal"
				android:gravity="right"
				android:paddingLeft="10px" >
				<TextView 
					android:id="@+id/lblAngleType"
					android:textColor="#000000"
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:text="Angle " />
				<TextView 
					android:id="@+id/angleType"
					android:textColor="#000000"
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:text="()" />
			</LinearLayout>
		</LinearLayout>
	
		<LinearLayout
			android:layout_width="fill_parent" 
			android:layout_height="wrap_content"
			android:orientation="horizontal"
			android:paddingLeft="5px" >
			<LinearLayout
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"
				android:orientation="vertical" >
		
			    <TextView android:id="@+id/lbla" 
					android:textColor="#000000"
			              android:text="Side a: "
						  android:layout_width="wrap_content"
			              android:layout_height="wrap_content"
			              android:paddingTop="12px" />
			    <TextView android:id="@+id/lblb" 
					android:textColor="#000000"
			              android:text="Side b: "
						  android:layout_width="wrap_content"
			              android:layout_height="wrap_content"
			              android:paddingTop="29px" />
			    <TextView android:id="@+id/lblc" 
					android:textColor="#000000"
			              android:text="Side c: "
						  android:layout_width="wrap_content"
			              android:layout_height="wrap_content"
			              android:paddingTop="29px" />
			</LinearLayout>
			
			<LinearLayout
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"
				android:layout_gravity="right"
				android:orientation="vertical" >
		
		    	<EditText 
			    	android:id="@+id/a"
			    	android:width="95px"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:inputType="numberDecimal"
			        android:singleLine="true"
			        android:lines="1"/>
			    <EditText 
			    	android:id="@+id/b"
			    	android:width="95px"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:inputType="numberDecimal"
			        android:singleLine="true"
			        android:lines="1"/>
			    <EditText 
			    	android:id="@+id/c"
			    	android:width="95px"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:inputType="numberDecimal"
			        android:singleLine="true"
			        android:lines="1"/>
			</LinearLayout>
			
			<LinearLayout
				android:layout_width="fill_parent" 
				android:layout_height="wrap_content"
				android:orientation="horizontal"
				android:gravity="right" >
				
				<LinearLayout
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:orientation="vertical" >
			
				    <TextView android:id="@+id/lblA" 
					android:textColor="#000000"
				              android:text="Angle A: "
							  android:layout_width="wrap_content"
				              android:layout_height="wrap_content"
				              android:paddingTop="12px" />
				    <TextView android:id="@+id/lblB" 
					android:textColor="#000000"
				              android:text="Angle B: "
							  android:layout_width="wrap_content"
				              android:layout_height="wrap_content"
				              android:paddingTop="29px" />
				    <TextView android:id="@+id/lblC" 
					android:textColor="#000000"
				              android:text="Angle C: "
							  android:layout_width="wrap_content"
				              android:layout_height="wrap_content"
				              android:paddingTop="29px" />
				</LinearLayout>
				
				<LinearLayout
					android:layout_width="wrap_content" 
					android:layout_height="wrap_content"
					android:orientation="vertical">
			
				    <EditText 
				    	android:id="@+id/A"
				    	android:width="95px"
						android:layout_width="wrap_content"
				        android:layout_height="wrap_content"
				        android:inputType="numberDecimal"
				        android:singleLine="true"
				        android:lines="1"/>
				    <EditText 
				    	android:id="@+id/B"
				    	android:width="95px"
						android:layout_width="wrap_content"
				        android:layout_height="wrap_content"
				        android:inputType="numberDecimal"
				        android:singleLine="true"
				        android:lines="1"/>
				    <EditText 
				    	android:id="@+id/C"
				    	android:width="95px"
						android:layout_width="wrap_content"
				        android:layout_height="wrap_content"
				        android:singleLine="true"
				        android:lines="1"
				        android:inputType="numberDecimal"/>
				</LinearLayout>
			</LinearLayout>
		</LinearLayout>	
		
		<LinearLayout
			android:layout_width="fill_parent" 
			android:layout_height="wrap_content"
			android:orientation="horizontal"
			android:paddingLeft="20px" >
			<LinearLayout
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"
				android:orientation="horizontal" >
				<TextView
					android:textColor="#000000"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:paddingTop="10px"
			        android:text="Area = " />
				<TextView
					android:textColor="#000000"
					android:id="@+id/area"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:paddingTop="10px"
			        android:numeric="decimal"
					android:inputType="none"
			        android:text="0.0" />
				<TextView
					android:textColor="#000000"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content"
			        android:paddingTop="10px"
			        android:text=" Units^2" />
			</LinearLayout>
			<LinearLayout
				android:layout_width="fill_parent" 
				android:layout_height="wrap_content"
				android:orientation="horizontal"
				android:gravity="right"
				android:paddingLeft="10px" >
				<Button
					android:id="@+id/clear"
					android:text="Clear"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content" />
				<Button
					android:id="@+id/calculate"
					android:text="Calculate"
					android:enabled="false"
					android:layout_width="wrap_content"
			        android:layout_height="wrap_content" />
			</LinearLayout>
		</LinearLayout>
	</LinearLayout>
</RelativeLayout>
 
... but when I keep moving down, past the last row, it gives me that exception....

Works fine for me on my Nexus One running 2.2

Either there's something else in your app, or maybe it's specific to the version of Android you're using.

Mark
 
Tried it on my G1 running 1.6, and got the exception.
It looks like it's a bug that they've fixed.

I guess your options are to work around the bug, or target a later version of Android.

Mark
 
Hmm... well I have a G1 that's running 1.6. I didn't want to build against a version that everyone won't have. I'm still a bit new to all this and even my G1, I can't find where to download and run a new version, is there a way to have my G1 device run a newer version?
 
1.6 is as far as I went with my G1.
I think that's the latest official version, but I stopped looking as soon as I got my Nexus One.
You might find that someone has hacked a later version to make it work.
 
Actually I think I found something that might be the problem. When running with 2.2 I noticed that when I select the left column and press the down arrow (or scroll down with the track ball), I can "select" the TextView and change the numbers in there. How do I tell the TextView not to be able to take any inputs. I thought it was inputType="none" but apparently that doesn't do it.
 
I figured it out! It now works with my 1.6 version as well.
Basically I specified that those TextViews are both inputMethod="none" and editable="false"
 
Back
Top Bottom