May I suggest instead of using catch(Exception ex) you should catch more specific exceptions. As now every exception will get caught by your catch, so even very unsuspected exceptions can get caught and still your app will keep running. The exception thrown by Integer.parse () is NumberFormatException (iirc).
On May 24, 2:39 am, chen hence <hencechen...@gmail.com> wrote: > i found the problem...its function add(); > Thank you for your help. > > 2009/5/23 chen hence <hencechen...@gmail.com> > > > > > public void menu_add(){ > > // > > setContentView(R.layout.add); > > Button btnadd=(Button)findViewById(R.id.addtips); > > Button btnreturn=(Button)findViewById(R.id.return_menu_record); > > //点击添加备注 > > btnadd.setOnClickListener(new View.OnClickListener(){ > > > public void onClick(View v) { > > // TODO Auto-generated method stub > > EditText et1=(EditText) findViewById(R.id.content); > > EditText et2=(EditText) findViewById(R.id.money); > > String con=et1.getText().toString(); > > try{ > > int money=Integer.parseInt(et2.getText().toString()); > > data.get(index).add(con, money); > > Dialog dlg=new Dialog(android01.this); > > dlg.setContentView(R.layout.succeed); > > dlg.show(); > > } > > catch(Exception ex){ > > Dialog dlg=new Dialog(android01.this); > > dlg.setContentView(R.layout.error); > > dlg.show(); > > } > > } > > }); > > btnreturn.setOnClickListener(new View.OnClickListener(){ > > > public void onClick(View v) { > > // TODO Auto-generated method stub > > menu_record(); > > } > > }); > > } > > > add.xml > > > <?xml version="1.0" encoding="utf-8"?> > > <LinearLayout > > android:id="@+id/widget30" > > android:layout_width="fill_parent" > > android:layout_height="fill_parent" > > xmlns:android="http://schemas.android.com/apk/res/android" > > android:orientation="vertical" > > > <TextView > > android:id="@+id/tx4" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="Content" > > > </TextView> > > <EditText > > android:id="@+id/content" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="What did you spend the money on?" > > android:textSize="18sp" > > > </EditText> > > <TextView > > android:id="@+id/tx5" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="Money" > > > </TextView> > > <EditText > > android:id="@+id/money" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="How much?" > > android:textSize="18sp" > > > </EditText> > > <Button > > android:id="@+id/addtips" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="add tips" > > > </Button> > > <Button > > android:id="@+id/return_menu_record" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:text="return" > > > </Button> > > </LinearLayout> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---