gpt4 book ai didi

android - 改变 Activity 的简单 Intent 不起作用

转载 作者:行者123 更新时间:2023-11-30 03:31:04 24 4
gpt4 key购买 nike

我正在尝试通过这样的 Intent 将 Activity 更改为打开嵌入式 Google map 的 fragment Activity :

Intent driver = new Intent(getApplicationContext(), DriverActivity.class);
startActivity(driver);

但是应用程序崩溃了,我最近从 Windows 上的 Eclipse 转移到了 Ubuntu 上的 Eclipse。我不明白为什么该应用程序不会更改 Activity 。调试器打开 layoutInflater.class,窗口内的消息是:找不到源

出了什么问题,我该如何解决?

07-04 19:47:09.828: E/AndroidRuntime(30884): FATAL EXCEPTION: main
07-04 19:47:09.828: E/AndroidRuntime(30884): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.setContentView(Activity.java:1867)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.codele.blackcab.DriverActivity.onCreate(DriverActivity.java:51)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Activity.performCreate(Activity.java:5008)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.access$600(ActivityThread.java:138)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.os.Looper.loop(Looper.java:213)
07-04 19:47:09.828: E/AndroidRuntime(30884): at android.app.ActivityThread.main(ActivityThread.java:4787)
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 19:47:09.828: E/AndroidRuntime(30884): at java.lang.reflect.Method.invoke(Method.java:511)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-04 19:47:09.828: E/AndroidRuntime(30884): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-04 19:47:09.828: E/AndroidRuntime(30884): at dalvik.system.NativeStart.main(Native Method)

最佳答案

使用这个:

Intent driver = new Intent(this, DriverActivity.class);
startActivity(driver);

关于android - 改变 Activity 的简单 Intent 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17476044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com