Unhandled Exception


Last Updated:

  1. emperorb2g

    emperorb2g New Member This Topic's Starter

    Joined:
    Jul 29, 2009
    Messages:
    1
    Likes Received:
    0
    Hi,

    I am creating 4 buttons in the linear layout at the very bottom of the screen using the below code snippet

    <LinearLayout
    android:clickable="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFFFFF" >

    <Button
    android:id="@+id/back"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:textColor="@color/darktext"
    android:text="Back"
    android:background="@drawable/blb_upr_r_btn"
    android:layout_marginRight="1px"
    android:layout_marginLeft="1px" android:clickable="true" android:ellipsize="none" />

    similarly other 3 buttons such as Add, Find and Next

    </LinearLayout>

    I initialised all 4 buttons inside the onClick() using the following snippet

    private Button back, add, find, next;

    back=(Button)findViewById(R.id.back);
    back.setOnClickListener(this);

    similarly other 3

    I am handling the same using onClickListener

    if(id==back.getId())
    {
    //code
    }
    else if(id==add.getId())
    {
    //code
    }
    else if(id==find.getId())
    {
    //code
    }
    else if(id==next.getId())
    {
    next.setText("Clicked");
    }

    But When i run the application and click on any of these 4 buttons the application closes telling some unhandled exception has occured, please help me to sort out this
     

    Advertisement
  2. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    I would advise you to use error handling (try-catch blocks) and provide some output to the debug log.

    See this thread for more info.

    Good luck!
     

Share This Page

Loading...