将字符串和Latlng从一个活动发送到另一个活动时出错

时间:2013-10-24 12:29:20

标签: android

我想从一个活动到另一个活动的一些变量,但我的应用程序崩溃了 我的日志:

10-24 17:31:05.765 E/AndroidRuntime(16529): FATAL EXCEPTION: main
10-24 17:31:05.765 E/AndroidRuntime(16529): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.restaurantfinder/com.example.restaurantfinder.RestaurantInfo}: android.content.res.Resources$NotFoundException: String resource ID #0x0
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread.access$600(ActivityThread.java:128)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.os.Looper.loop(Looper.java:137)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread.main(ActivityThread.java:4517)
10-24 17:31:05.765 E/AndroidRuntime(16529): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:31:05.765 E/AndroidRuntime(16529): at java.lang.reflect.Method.invoke(Method.java:511)
10-24 17:31:05.765 E/AndroidRuntime(16529): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
10-24 17:31:05.765 E/AndroidRuntime(16529): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
10-24 17:31:05.765 E/AndroidRuntime(16529): at dalvik.system.NativeStart.main(Native Method)
10-24 17:31:05.765 E/AndroidRuntime(16529): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.content.res.Resources.getText(Resources.java:260)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.widget.TextView.setText(TextView.java:3680)
10-24 17:31:05.765 E/AndroidRuntime(16529): at com.example.restaurantfinder.RestaurantInfo.onCreate(RestaurantInfo.java:49)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.Activity.performCreate(Activity.java:4470)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
10-24 17:31:05.765 E/AndroidRuntime(16529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
10-24 17:31:05.765 E/AndroidRuntime(16529): ... 11 more

这是我的代码

  view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(context,RestaurantInfo.class);
                intent.putExtra("name", restaurantDetailList.get(position).getRestaurantName());
                Bundle args=new Bundle();
                args.putParcelable("geopiont", restaurantDetailList.get(position).getGeoPiont());
                intent.putExtra("bundle", args);
                intent.putExtra("address", restaurantDetailList.get(position).getAddress());
                intent.putExtra("type", restaurantDetailList.get(position).getType());
                intent.putExtra("flag",(restaurantDetailList.get(position).getFlag()));
                context.startActivity(intent);

                }
        });
        return view;

1 个答案:

答案 0 :(得分:1)

你必须将lat long设置为textview ...请将你的latlng转换为String,然后将其设置为textview,如下所示;

yourtextview.setText(latlng+"");

yourtextview.setText(String.ValueOf(latlng));

希望它会有所帮助。