gpt4 book ai didi

android - 之后实现 GreenDroid

转载 作者:行者123 更新时间:2023-11-29 18:12:20 27 4
gpt4 key购买 nike

我刚刚将 GreenDroid 库添加到我的应用程序中。我用 GDActivity 扩展了 startview 并添加了 NFFApplication 并添加到应用程序标签 android:name=".logic.NFFApplication" 下的 list 中。

NFFA应用:

public class NFFApplication extends GDApplication {

@Override
public Class<?> getHomeActivityClass() {
return NFFApplication.class;
}

@Override
public Intent getMainApplicationIntent() {
return new Intent(NFFApplication.this,MainView.class);
}

}

登录 Activity :

public class LoginView extends GDActivity {

private ProgressDialog pd = null;
Editor editor = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setTitle("Movie");
setActionBarContentView(R.layout.loginlayout);

日志:

04-05 16:12:16.714: E/AndroidRuntime(443): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.korn.nff/com.korn.nff.view.LoginView}: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.os.Looper.loop(Looper.java:123)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-05 16:12:16.714: E/AndroidRuntime(443): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443): at java.lang.reflect.Method.invoke(Method.java:521)
04-05 16:12:16.714: E/AndroidRuntime(443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-05 16:12:16.714: E/AndroidRuntime(443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-05 16:12:16.714: E/AndroidRuntime(443): at dalvik.system.NativeStart.main(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-05 16:12:16.714: E/AndroidRuntime(443): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.Activity.setContentView(Activity.java:1622)
04-05 16:12:16.714: E/AndroidRuntime(443): at greendroid.app.GDActivity.ensureLayout(GDActivity.java:187)
04-05 16:12:16.714: E/AndroidRuntime(443): at greendroid.app.GDActivity.getActionBar(GDActivity.java:265)
04-05 16:12:16.714: E/AndroidRuntime(443): at greendroid.app.GDActivity.setTitle(GDActivity.java:256)
04-05 16:12:16.714: E/AndroidRuntime(443): at com.korn.nff.view.LoginView.onCreate(LoginView.java:39)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-05 16:12:16.714: E/AndroidRuntime(443): ... 11 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: java.lang.reflect.InvocationTargetException
04-05 16:12:16.714: E/AndroidRuntime(443): at greendroid.widget.ActionBar.<init>(ActionBar.java:130)
04-05 16:12:16.714: E/AndroidRuntime(443): at java.lang.reflect.Constructor.constructNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-05 16:12:16.714: E/AndroidRuntime(443): ... 24 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/title_bar_shadow.9.png from drawable resource ID #0x0
04-05 16:12:16.714: E/AndroidRuntime(443): at android.content.res.Resources.loadDrawable(Resources.java:1710)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.View.<init>(View.java:1850)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.View.<init>(View.java:1799)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.view.ViewGroup.<init>(ViewGroup.java:284)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.widget.LinearLayout.<init>(LinearLayout.java:92)
04-05 16:12:16.714: E/AndroidRuntime(443): at greendroid.widget.ActionBar.<init>(ActionBar.java:134)
04-05 16:12:16.714: E/AndroidRuntime(443): ... 28 more
04-05 16:12:16.714: E/AndroidRuntime(443): Caused by: java.io.FileNotFoundException: res/drawable-hdpi/title_bar_shadow.9.png
04-05 16:12:16.714: E/AndroidRuntime(443): at android.content.res.AssetManager.openNonAssetNative(Native Method)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.content.res.AssetManager.openNonAsset(AssetManager.java:390)
04-05 16:12:16.714: E/AndroidRuntime(443): at android.content.res.Resources.loadDrawable(Resources.java:1702)

最佳答案

我不是 100% 确定这是否是问题所在,但会不会是您忘记覆盖主题了? Greendroid 需要自定义主题才能使应用程序运行。

这是 greendroid 文档中的一行:

You finally need to make your project use the GreenDroid base theme. In your AndroidManifest.xml, go to the application tag and add android:theme="@style/Theme.GreenDroid" as a new attribute.

您必须遵循的步骤:

  1. 在您的计算机上使用简单的 git 下载 GreenDroid 库克隆 http://github.com/cyrilmottier/GreenDroid.git .像往常一样,Git将克隆 GreenDroid 存储库并创建一个文件夹 GreenDroid包含 3 个文件夹: GreenDroid:核心库。这是将主要链接到您的代码的代码 GreenDroid-GoogleAPIs:GreenDroid 的扩展,包括与 Google APIs 相关的功能(例如 GDMapActivity) GDCatalog:演示应用程序。该项目包含大量代码 fragment ,向您展示如何使用 GreenDroid。

  2. 自 2010 年 5 月以来,ADT 插件添加了一项惊人的新功能:与图书馆项目合作的能力。使用 GreenDroid 包括将 GreenDroid 项目作为库应用到您的应用程序。 A关于如何使用库项目的完整描述在安卓文档网站。确保你的发展环境使用最新的工具和平台,因为旧工具和平台的发布不支持构建图书馆项目。

  3. 如果您想使用某些 Google API 功能,请确保您使用 GreenDroid-GoogleAPIs 库。 GreenDroid-GoogleAPIs 是基于 GreenDroid。因此,您不需要链接 GreenDroid作为您项目的 Android 库。默认情况下,GreenDroid主题继承自@android:style/Theme。如果你的项目继承来自不同的主题,你必须修改 GreenDroid 库自己(每次更新 GreenDroid 时都这样做更新会删除您的所有更改 - 仍在努力克服这个问题)。打开 res/values/gd_themes.xml 和将父主题 @android:style/Theme 替换为您自己的主题。

  4. 许多 GreenDroid 的功能(GDActivity、GDListActivity 或GDTabActivity 例如)需要你的应用程序是一个GDApplication 所以确保你的应用程序是一个 GDApplication类(class)。为此,只需添加android:name="greendroid.app.GDApplication(其中greendroid.app.GDApplication 可以替换为你自己的类继承自 GDApplication) 在你的应用程序标签中AndroidManifest.xml。

  5. 您最终需要让您的项目使用 GreenDroid 基本主题。在您的 AndroidManifest.xml 中,转到应用程序标签并添加android:theme="@style/Theme.GreenDroid"作为新属性。

关于android - 之后实现 GreenDroid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10032255/

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