首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >事后实现GreenDroid

事后实现GreenDroid
EN

Stack Overflow用户
提问于 2012-04-06 00:18:06
回答 1查看 1.3K关注 0票数 1

我刚刚将GreenDroid库添加到我的应用程序中。我用GDActivity扩展了开始视图,添加了NFFApplication,并添加到应用程序标记android:name=".logic.NFFApplication"下的清单中。

NFFAplication:

代码语言:javascript
复制
public class NFFApplication extends GDApplication {

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

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

}

登录活动:

代码语言:javascript
复制
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);

LogCat:

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-06 00:25:48

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

下面是greendroid文档中的代码行:

代码语言:javascript
复制
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克隆http://github.com/cyrilmottier/GreenDroid.git将GreenDroid库下载到您的计算机上。像往常一样,Git将克隆GreenDroid存储库,并创建一个包含3个文件夹的文件夹GreenDroid: GreenDroid :核心库。这是主要链接到您的代码的代码GreenDroid-GoogleAPIs: GreenDroid的扩展,包括与GoogleAPI相关的特性(例如GDMapActivity) GDCatalog:演示应用程序。该项目包含大量代码片段,向您展示如何使用GreenDroid.
  2. Since。2010年5月,ADT插件添加了一个令人惊叹的新功能:能够使用库项目。使用GreenDroid包括将GreenDroid项目作为库应用于您的应用程序。Android文档网站上提供了有关如何使用库项目的完整描述。请确保您的开发环境使用最新的工具和平台,因为旧版本的工具和平台不支持使用库项目构建。
  3. 如果您想要使用某些Google API功能,请确保您使用的是GreenDroid-GoogleAPI库。GreenDroid -GoogleAPI基于GreenDroid。因此,您不需要将GreenDroid作为安卓库链接到您的项目。默认情况下,样式主题继承自@android: GreenDroid / theme。如果你的项目继承了一个不同的主题,你将不得不自己修改GreenDroid库(每次你更新GreenDroid时都要这样做,因为更新会删除所有的更改--仍然在努力克服这个问题)。
  4. 很多GreenDroid的特性(比如GDActivity、GDListActivity或GDTabActivity )都需要你的应用程序是一个GDApplication,所以要确保你的应用程序是一个GDApplication类。为此,只需在AndroidManifest.xml.
  5. You的应用程序标记中添加android:name="greendroid.app.GDApplication (其中greendroid.app.GDApplication可能会被您自己的继承自GDApplication的类替换)最终需要使您的项目使用GreenDroid基本主题。在AndroidManifest.xml中,转到应用程序标记并添加android:theme="@style/Theme.GreenDroid“作为新属性。
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10032255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档