Tuesday, April 30, 2013

[android help] List View Item row click Caused by: java.lang.NumberFormatException


I am writing a Cart App in which i need to open that particular item in an activity, which has been clicked by the user in List View.


I am using two different activities, one to show selected Item(s) in a List View namely CartActivity.java and second to show any of the selected item in another activity namely ProductInformationActivity.java


I have written code to call that particular item in an activity, which has been selected by user, in a List View of CartActivity.java


CartAdapter.java:



public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.listrow_cart, null);
vi.setClickable(true);
vi.setFocusable(true);
vi.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v)
{
HashMap prod = new HashMap();
prod = Constants.mItem_Detail.get(position);
Intent mViewCartIntent = new Intent
(activity,ProductInformationActivity.class);
mViewCartIntent.putExtra("product", prod);
activity.startActivity(mViewCartIntent);
}
});


ProductInformationActivity.java:



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information_product);

// below is the line number 77

itemamount = Double.parseDouble(text_cost_code.getText().toString());
txt_total.setText(Double.toString(itemamount));
edit_qty_code.addTextChangedListener(new TextWatcher() {


But whenever i do click on any of the item in a ListView, i am not getting that particular item in ProductInformationActivity.java, getting an Error message that says : Force Close Logcat Says:



04-30 14:37:10.073: E/AndroidRuntime(273): FATAL EXCEPTION: main
04-30 14:37:10.073: E/AndroidRuntime(273): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.era.restaurant.versionoct/com.era.restaurant.versionoct.menu.ProductInformationActivity}: java.lang.NumberFormatException:
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.os.Looper.loop(Looper.java:123)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-30 14:37:10.073: E/AndroidRuntime(273): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 14:37:10.073: E/AndroidRuntime(273): at java.lang.reflect.Method.invoke(Method.java:521)
04-30 14:37:10.073: E/AndroidRuntime(273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-30 14:37:10.073: E/AndroidRuntime(273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-30 14:37:10.073: E/AndroidRuntime(273): at dalvik.system.NativeStart.main(Native Method)
04-30 14:37:10.073: E/AndroidRuntime(273): Caused by: java.lang.NumberFormatException:
04-30 14:37:10.073: E/AndroidRuntime(273): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267)
04-30 14:37:10.073: E/AndroidRuntime(273): at java.lang.Double.parseDouble(Double.java:287)
04-30 14:37:10.073: E/AndroidRuntime(273): at com.era.restaurant.versionoct.menu.ProductInformationActivity.onCreate(ProductInformationActivity.java:77)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 14:37:10.073: E/AndroidRuntime(273): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-30 14:37:10.073: E/AndroidRuntime(273): ... 11 more


.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...