IndexOutOfBoundsException when moving through EditBoxess


Last Updated:

  1. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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)
     

    Advertisement
  2. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    Does anyone know why this is happening? I still have no idea...
     
  3. markb

    markb Well-Known Member

    Joined:
    Sep 14, 2009
    Messages:
    148
    Likes Received:
    26
    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.)
     
  4. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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]
     
  5. markb

    markb Well-Known Member

    Joined:
    Sep 14, 2009
    Messages:
    148
    Likes Received:
    26
    Can you post your layout? (using CODE tags)
    I'm going to have to reproduce your problem in order to investigate it.

    Mark
     
  6. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    Code (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <RelativeLayout
    4.     xmlns:android="http://schemas.android.com/apk/res/android"
    5.     android:layout_width="fill_parent"
    6.     android:layout_height="fill_parent">
    7.    
    8.     <RelativeLayout
    9.         android:layout_width="fill_parent"
    10.         android:layout_height="wrap_content">
    11.         <ImageView
    12.             android:id="@+id/background"
    13.             android:layout_width="wrap_content"
    14.             android:layout_height="wrap_content"
    15.             android:scaleType="fitXY"
    16.             android:src="@drawable/back_v" />
    17.         <ImageView
    18.             android:id="@+id/image"
    19.             android:paddingTop="25px"
    20.             android:layout_width="fill_parent"
    21.             android:layout_height="wrap_content"
    22.             android:src="@drawable/right" />
    23.         <RelativeLayout
    24.             android:layout_width="fill_parent"
    25.             android:layout_height="wrap_content"
    26.             android:gravity="right"
    27.             android:paddingRight="2px"
    28.             android:paddingTop="5px">
    29.             <Button
    30.                 android:id="@+id/how"
    31.                 android:text="Show The Work!"
    32.                 android:enabled="false"
    33.                 android:layout_width="wrap_content"
    34.                 android:layout_height="wrap_content" />
    35.         </RelativeLayout>
    36.     </RelativeLayout>
    37.        
    38.     <LinearLayout
    39.         android:layout_width="fill_parent"
    40.         android:layout_height="wrap_content"
    41.         android:orientation="vertical"
    42.         android:paddingTop="220px"
    43.         android:paddingRight="4px"
    44.         android:paddingLeft="5px" >
    45.         <LinearLayout
    46.             android:layout_width="fill_parent"
    47.             android:layout_height="wrap_content"
    48.             android:orientation="horizontal">
    49.             <LinearLayout
    50.                 android:layout_width="wrap_content"
    51.                 android:layout_height="wrap_content"
    52.                 android:orientation="horizontal" >
    53.                 <TextView
    54.                     android:id="@+id/lblRounding"
    55.                     android:textColor="#000000"
    56.                     android:layout_width="wrap_content"
    57.                     android:layout_height="wrap_content"
    58.                     android:text="Length " />
    59.                 <TextView
    60.                     android:id="@+id/rounding"
    61.                     android:textColor="#000000"
    62.                     android:layout_width="wrap_content"
    63.                     android:layout_height="wrap_content"
    64.                     android:text="()" />
    65.             </LinearLayout>
    66.             <LinearLayout
    67.                 android:layout_width="fill_parent"
    68.                 android:layout_height="wrap_content"
    69.                 android:orientation="horizontal"
    70.                 android:gravity="right"
    71.                 android:paddingLeft="10px" >
    72.                 <TextView
    73.                     android:id="@+id/lblAngleType"
    74.                     android:textColor="#000000"
    75.                     android:layout_width="wrap_content"
    76.                     android:layout_height="wrap_content"
    77.                     android:text="Angle " />
    78.                 <TextView
    79.                     android:id="@+id/angleType"
    80.                     android:textColor="#000000"
    81.                     android:layout_width="wrap_content"
    82.                     android:layout_height="wrap_content"
    83.                     android:text="()" />
    84.             </LinearLayout>
    85.         </LinearLayout>
    86.    
    87.         <LinearLayout
    88.             android:layout_width="fill_parent"
    89.             android:layout_height="wrap_content"
    90.             android:orientation="horizontal"
    91.             android:paddingLeft="5px" >
    92.             <LinearLayout
    93.                 android:layout_width="wrap_content"
    94.                 android:layout_height="wrap_content"
    95.                 android:orientation="vertical" >
    96.        
    97.                 <TextView android:id="@+id/lbla"
    98.                     android:textColor="#000000"
    99.                           android:text="Side a: "
    100.                           android:layout_width="wrap_content"
    101.                           android:layout_height="wrap_content"
    102.                           android:paddingTop="12px" />
    103.                 <TextView android:id="@+id/lblb"
    104.                     android:textColor="#000000"
    105.                           android:text="Side b: "
    106.                           android:layout_width="wrap_content"
    107.                           android:layout_height="wrap_content"
    108.                           android:paddingTop="29px" />
    109.                 <TextView android:id="@+id/lblc"
    110.                     android:textColor="#000000"
    111.                           android:text="Side c: "
    112.                           android:layout_width="wrap_content"
    113.                           android:layout_height="wrap_content"
    114.                           android:paddingTop="29px" />
    115.             </LinearLayout>
    116.            
    117.             <LinearLayout
    118.                 android:layout_width="wrap_content"
    119.                 android:layout_height="wrap_content"
    120.                 android:layout_gravity="right"
    121.                 android:orientation="vertical" >
    122.        
    123.                 <EditText
    124.                     android:id="@+id/a"
    125.                     android:width="95px"
    126.                     android:layout_width="wrap_content"
    127.                     android:layout_height="wrap_content"
    128.                     android:inputType="numberDecimal"
    129.                     android:singleLine="true"
    130.                     android:lines="1"/>
    131.                 <EditText
    132.                     android:id="@+id/b"
    133.                     android:width="95px"
    134.                     android:layout_width="wrap_content"
    135.                     android:layout_height="wrap_content"
    136.                     android:inputType="numberDecimal"
    137.                     android:singleLine="true"
    138.                     android:lines="1"/>
    139.                 <EditText
    140.                     android:id="@+id/c"
    141.                     android:width="95px"
    142.                     android:layout_width="wrap_content"
    143.                     android:layout_height="wrap_content"
    144.                     android:inputType="numberDecimal"
    145.                     android:singleLine="true"
    146.                     android:lines="1"/>
    147.             </LinearLayout>
    148.            
    149.             <LinearLayout
    150.                 android:layout_width="fill_parent"
    151.                 android:layout_height="wrap_content"
    152.                 android:orientation="horizontal"
    153.                 android:gravity="right" >
    154.                
    155.                 <LinearLayout
    156.                     android:layout_width="wrap_content"
    157.                     android:layout_height="wrap_content"
    158.                     android:orientation="vertical" >
    159.            
    160.                     <TextView android:id="@+id/lblA"
    161.                     android:textColor="#000000"
    162.                               android:text="Angle A: "
    163.                               android:layout_width="wrap_content"
    164.                               android:layout_height="wrap_content"
    165.                               android:paddingTop="12px" />
    166.                     <TextView android:id="@+id/lblB"
    167.                     android:textColor="#000000"
    168.                               android:text="Angle B: "
    169.                               android:layout_width="wrap_content"
    170.                               android:layout_height="wrap_content"
    171.                               android:paddingTop="29px" />
    172.                     <TextView android:id="@+id/lblC"
    173.                     android:textColor="#000000"
    174.                               android:text="Angle C: "
    175.                               android:layout_width="wrap_content"
    176.                               android:layout_height="wrap_content"
    177.                               android:paddingTop="29px" />
    178.                 </LinearLayout>
    179.                
    180.                 <LinearLayout
    181.                     android:layout_width="wrap_content"
    182.                     android:layout_height="wrap_content"
    183.                     android:orientation="vertical">
    184.            
    185.                     <EditText
    186.                         android:id="@+id/A"
    187.                         android:width="95px"
    188.                         android:layout_width="wrap_content"
    189.                         android:layout_height="wrap_content"
    190.                         android:inputType="numberDecimal"
    191.                         android:singleLine="true"
    192.                         android:lines="1"/>
    193.                     <EditText
    194.                         android:id="@+id/B"
    195.                         android:width="95px"
    196.                         android:layout_width="wrap_content"
    197.                         android:layout_height="wrap_content"
    198.                         android:inputType="numberDecimal"
    199.                         android:singleLine="true"
    200.                         android:lines="1"/>
    201.                     <EditText
    202.                         android:id="@+id/C"
    203.                         android:width="95px"
    204.                         android:layout_width="wrap_content"
    205.                         android:layout_height="wrap_content"
    206.                         android:singleLine="true"
    207.                         android:lines="1"
    208.                         android:inputType="numberDecimal"/>
    209.                 </LinearLayout>
    210.             </LinearLayout>
    211.         </LinearLayout>
    212.        
    213.         <LinearLayout
    214.             android:layout_width="fill_parent"
    215.             android:layout_height="wrap_content"
    216.             android:orientation="horizontal"
    217.             android:paddingLeft="20px" >
    218.             <LinearLayout
    219.                 android:layout_width="wrap_content"
    220.                 android:layout_height="wrap_content"
    221.                 android:orientation="horizontal" >
    222.                 <TextView
    223.                     android:textColor="#000000"
    224.                     android:layout_width="wrap_content"
    225.                     android:layout_height="wrap_content"
    226.                     android:paddingTop="10px"
    227.                     android:text="Area = " />
    228.                 <TextView
    229.                     android:textColor="#000000"
    230.                     android:id="@+id/area"
    231.                     android:layout_width="wrap_content"
    232.                     android:layout_height="wrap_content"
    233.                     android:paddingTop="10px"
    234.                     android:numeric="decimal"
    235.                     android:inputType="none"
    236.                     android:text="0.0" />
    237.                 <TextView
    238.                     android:textColor="#000000"
    239.                     android:layout_width="wrap_content"
    240.                     android:layout_height="wrap_content"
    241.                     android:paddingTop="10px"
    242.                     android:text=" Units^2" />
    243.             </LinearLayout>
    244.             <LinearLayout
    245.                 android:layout_width="fill_parent"
    246.                 android:layout_height="wrap_content"
    247.                 android:orientation="horizontal"
    248.                 android:gravity="right"
    249.                 android:paddingLeft="10px" >
    250.                 <Button
    251.                     android:id="@+id/clear"
    252.                     android:text="Clear"
    253.                     android:layout_width="wrap_content"
    254.                     android:layout_height="wrap_content" />
    255.                 <Button
    256.                     android:id="@+id/calculate"
    257.                     android:text="Calculate"
    258.                     android:enabled="false"
    259.                     android:layout_width="wrap_content"
    260.                     android:layout_height="wrap_content" />
    261.             </LinearLayout>
    262.         </LinearLayout>
    263.     </LinearLayout>
    264. </RelativeLayout>
    265.  
    266.  
     
  7. markb

    markb Well-Known Member

    Joined:
    Sep 14, 2009
    Messages:
    148
    Likes Received:
    26
    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
     
  8. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    It doesn't work when running under 1.6. Is there anything about 1.6 that makes that happen?
     
  9. markb

    markb Well-Known Member

    Joined:
    Sep 14, 2009
    Messages:
    148
    Likes Received:
    26
    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
     
  10. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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?
     
  11. markb

    markb Well-Known Member

    Joined:
    Sep 14, 2009
    Messages:
    148
    Likes Received:
    26
    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.
     
  12. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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.
     
  13. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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"
     

Share This Page

Loading...