Aller au contenu

Recommended Posts

Posté(e)

bonjour à tous

je suis nouveau sur le forum. Je m'interesse au dev android depuis peu, et je galere sur un probleme depuis 1 semaine. assez de blabla, voila mes infos
j'utilise https://github.com/kikoso/Swipeable-Cards un Tinder like 
c'est tres bien, mais il utilise des images deja dans le projet (repertoire Drawable). Je cherche donc à telecharger des images depuis mon serveur et à construire chaque carte avec cette image de la facon suivante : 

String MonImageTest ="http://fc03.deviantart.net/fs70/f/2013/012/e/c/png_cookie_by_ellatutorials-d5r8nel.png";



adapter.add(new CardModel(ID, "Mon Texte", ImageManager.getDrawableFromWebOperation(MonImageTest)));
en utilisant le code suivant : 
/**
* get Drawable from a URL request
* @param url
* @return Drawable
*/
public static Drawable getDrawableFromWebOperation(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, url);
return d;
}
catch (Exception e) {
Log.e(LOG_TAG, e.getMessage());
return null;
}
}

le layout est le suivant :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<com.glopper.andtinder.view.CardContainer
android:id="@+id/layoutview"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_weight="0.25"
app:orientation="ordered"/>

<!-- <com.glopper.andtinder.view.CardContainer
android:id="@+id/layoutview2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:orientation="ordered"/> -->

<ImageButton
style="@style/Base.TextAppearance.AppCompat.Display4"
android:id="@+id/btnRegister"
android:background="@drawable/user"
android:clickable="true"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />


</LinearLayout>


et les erreurs, puisque c'est bien cela le probleme icon_wink.gif :
Process: com.glopper, PID: 13036
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.glopper/com.glopper.ShowCards}: java.lang.NullPointerException: println needs a message
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2394)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:307)
at com.glopper.ImageManager.getDrawableFromWebOperation(ImageManager.java:33)
at com.glopper.ShowCards.onCreate(ShowCards.java:150)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
************at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
************at android.app.ActivityThread.access$900(ActivityThread.java:172)
************at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
************at android.os.Handler.dispatchMessage(Handler.java:102)
************at android.os.Looper.loop(Looper.java:136)
************at android.app.ActivityThread.main(ActivityThread.java:5586)
************at java.lang.reflect.Method.invokeNative(Native Method)
************at java.lang.reflect.Method.invoke(Method.java:515)
************at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
************at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
************at dalvik.system.NativeStart.main(Native Method)

erreurs sur la ligne
final CardModel cardModel = new CardModel(IDSender, "Glop de " + Pseudo, LeTitre + " : " + LeMessage2, ImageManager.getDrawableFromWebOperation(MonImageTest));
et 
Log.e(LOG_TAG, e.getMessage());

voila si qqun a une idee pour me depatouiller, j'apprecierai grandement 

gloubi

Posté(e)

Déjà ton Log.e génère une exception, donc on ne voit pas l'erreur.

 

Je pense que tu as oublié de définir ton tag: LOG_TAG.

 

Ajoute-le et montre la véritable erreur. :)

Rejoignez la conversation

Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.

Invité
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Répondre à ce sujet…

×   Collé en tant que texte enrichi.   Coller en tant que texte brut à la place

  Seulement 75 émoticônes maximum sont autorisées.

×   Votre lien a été automatiquement intégré.   Afficher plutôt comme un lien

×   Votre contenu précédent a été rétabli.   Vider l’éditeur

×   Vous ne pouvez pas directement coller des images. Envoyez-les depuis votre ordinateur ou insérez-les depuis une URL.

×
×
  • Créer...