Aller au contenu

GreenDroid: GDTabActivity


steph29

Recommended Posts

Bonjour à tous,

je viens de me décider à tester Greendroid. Les possibilités de cette library semblent vraiment bonnes. Ce que je recherche c'est des petites fonctions pour customiser facilement mon UI.

Je m'intéresse donc en ce moment à GDTabActivity. (Il faut dire que les tab Android, de base, c'est pas très jolie).

Donc, je m'y suis mis, et j'obtiens une exception que je n'arrive pas à résoudre. Peut être une erreur dans le fichier manifest.

Etant donné que je ne veux pas d'actionbar, peut être un contournement serait de la supprimer.

Merci d'avance pour votre aide!

Voici mon code:

Activité

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import greendroid.app.GDTabActivity;

public class Tabs extends GDTabActivity {

@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       //setTitle("Screen 2");


       //getActionBar().setVisibility(View.GONE);
       Intent intent = new Intent(this, Search.class);
       addTab("TAB1", this.getString(R.string.tab_search), intent);

       intent = new Intent(this, MyAnnounces.class);
       addTab("TAB2", this.getString(R.string.tab_my), intent);

       intent = new Intent(this, Favorite.class);
       addTab("TAB3", this.getString(R.string.tab_favoris), intent);

       intent = new Intent(this, Account.class);
       addTab("TAB4", this.getString(R.string.tab_account), intent);
}
}

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="me.activities"
     android:versionCode="1"
     android:versionName="1.0">

   <application android:icon="@drawable/icon" android:label="@string/app_name"
   	android:name="greendroid.app.GDApplication">

   	<activity android:name="greendroid.app.GDMapActivity"></activity>
   	<activity android:name="greendroid.app.GDTabActivity"/>


       <activity android:name=".Account"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
           </intent-filter>
       </activity>

       <activity android:name=".Favorite"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
           </intent-filter>
       </activity>

       <activity android:name=".My"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
           </intent-filter>
       </activity>

       <activity android:name=".Tabs"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
           </intent-filter>
       </activity>


       <activity android:name="Search"
                 android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
           </intent-filter>
       </activity>

   </application>
</manifest>

Voici mon exception

04-26 23:03:47.445: ERROR/ActivityThread(8396): Failed to inflate
04-26 23:03:47.445: ERROR/ActivityThread(8396): android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:211)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.Activity.setContentView(Activity.java:1657)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at greendroid.app.GDTabActivity.onCreate(GDTabActivity.java:50)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at me.activities.Tabs.onCreate(Tabs.java:15)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1731)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1793)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.os.Looper.loop(Looper.java:123)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.app.ActivityThread.main(ActivityThread.java:3848)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at java.lang.reflect.Method.invokeNative(Native Method)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at java.lang.reflect.Method.invoke(Method.java:507)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at dalvik.system.NativeStart.main(Native Method)
04-26 23:03:47.445: ERROR/ActivityThread(8396): Caused by: java.lang.reflect.InvocationTargetException
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at java.lang.reflect.Constructor.constructNative(Native Method)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     ... 22 more
04-26 23:03:47.445: ERROR/ActivityThread(8396): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01002a a=-1}
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.content.res.Resources.loadDrawable(Resources.java:1754)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.View.<init>(View.java:1967)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.View.<init>(View.java:1915)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.view.ViewGroup.<init>(ViewGroup.java:286)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at android.widget.LinearLayout.<init>(LinearLayout.java:120)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at greendroid.widget.ActionBar.<init>(ActionBar.java:83)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     at greendroid.widget.ActionBar.<init>(ActionBar.java:79)
04-26 23:03:47.445: ERROR/ActivityThread(8396):     ... 25 more

Lien vers le commentaire
Partager sur d’autres sites

Bon après l'ajout de

android:theme="@style/Theme.GreenDroid"

Toujours une exception :

04-28 20:32:00.296: ERROR/AndroidRuntime(1237): FATAL EXCEPTION: main
04-28 20:32:00.296: ERROR/AndroidRuntime(1237): java.lang.RuntimeException: Unable to start activity ComponentInfo{dealz.me.activities/dealz.me.activities.Tabs}: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.os.Looper.loop(Looper.java:123)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at java.lang.reflect.Method.invokeNative(Native Method)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at java.lang.reflect.Method.invoke(Method.java:521)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at dalvik.system.NativeStart.main(Native Method)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237): Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class greendroid.widget.ActionBar
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.Activity.setContentView(Activity.java:1647)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at greendroid.app.GDTabActivity.onCreate(GDTabActivity.java:50)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at dealz.me.activities.Tabs.onCreate(Tabs.java:12)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     ... 11 more
04-28 20:32:00.296: ERROR/AndroidRuntime(1237): Caused by: java.lang.reflect.InvocationTargetException
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at greendroid.widget.ActionBar.<init>(ActionBar.java:79)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at java.lang.reflect.Constructor.constructNative(Native Method)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     ... 22 more
04-28 20:32:00.296: ERROR/AndroidRuntime(1237): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-mdpi/title_bar_shadow.9.png from drawable resource ID #0x0
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.content.res.Resources.loadDrawable(Resources.java:1714)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.View.<init>(View.java:1885)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.View.<init>(View.java:1834)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.view.ViewGroup.<init>(ViewGroup.java:285)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.widget.LinearLayout.<init>(LinearLayout.java:115)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at greendroid.widget.ActionBar.<init>(ActionBar.java:83)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     ... 26 more
04-28 20:32:00.296: ERROR/AndroidRuntime(1237): Caused by: java.io.FileNotFoundException: res/drawable-mdpi/title_bar_shadow.9.png
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.content.res.AssetManager.openNonAssetNative(Native Method)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.content.res.AssetManager.openNonAsset(AssetManager.java:405)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     at android.content.res.Resources.loadDrawable(Resources.java:1706)
04-28 20:32:00.296: ERROR/AndroidRuntime(1237):     ... 32 more

Lien vers le commentaire
Partager sur d’autres sites

a priori, tu as une erreur avec l'image qu'il cherche dans res/drawable-mdpi/title_bar_shadow.9.png

Il te manque peut etre ce fichier car tu lui demande d'afficher cette image pour ton actionBar, cette image ne vient pas, a priori, de GreenDroid. puisque toutes les ressources sont préfixé de GD_.

Sinon l'erreur vient peut etre du fait que tu ne définies rien dans ton actionBar ce qui fait que l'application va chercher par default title_bar_shadow.9.png

Lien vers le commentaire
Partager sur d’autres sites

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

×
×
  • Créer...