9
votes

Nosuchmethoderror quand j'utilise android.widget.relatelayAnt.setBackground

à Android 4.2 Mon application fonctionne bien, mais lorsque j'essaie de le tester à l'aide d'Android 4.0.4 J'ai cette erreur de message: xxx pré>

J'utilise setbackgroud pour ajouter une animation groud pour ajouter une animation, comme ça Code p>

AnimationDrawable animation = new AnimationDrawable();
                                 animation.addFrame(getResources().getDrawable(R.drawable.d1), 200);
                                 animation.addFrame(getResources().getDrawable(R.drawable.dio), 1000);
                                 animation.addFrame(getResources().getDrawable(R.drawable.da1), 200);
 animation.setOneShot(true);
 view.setBackground(animation);
 view.post(new Starter(animation));


2 commentaires

Qu'y a-t-il dans MainActivity.java:271? Quel est le type de vue dans `View.setbackground (animation); ' ?


Lisez la DOC, le ferbackgroundDrawable n'existe pas avant l'API 16.


4 Réponses :



31
votes

En plus de @dmon Réponse: Vous pouvez appeler la méthode appropriée de cette manière: xxx


0 commentaires

2
votes

Essayez ceci, cela a fonctionné pour moi:

p>

Bitmap bitmap = BitmapFactory.decodeFile(new ImageLoader().fullPath + "/desiredFilename.png");
Resources res = getResources();
BitmapDrawable bitmapDrawable = new BitmapDrawable(res, bitmap);
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN)
   ll.setBackgroundDrawable(bitmapDrawable);
else 
   ll.setBackground(bitmapDrawable);


0 commentaires

0
votes

C'était mon problème:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    imageButton.setOnTouchListener(popupWindow.createDragToOpenListener(imageButton));
                }


0 commentaires