android - Best way of making a class for an object? -


i'm trying create game. need kitten object image displayed. need use object within multiple activities decided it's better using outside class.

i used this. function findviewbyid(int) not aviable outside activity. how this?

public class kitten {     context parent;     view parentview;     imageview imgbody, imghead;      kitten(context context, view view) {         parent = context;         parentview = view;          //create body & head         imgbody = new imageview(parent);         imgbody.setimageresource(r.mipmap.img_kitty_body_white);         addimage(imgbody);         imghead = new imageview(parent);         imghead.setimageresource(r.mipmap.img_kitty_head_white);         addimage(imghead);     }      private void addimage(imageview img) {         relativelayout rl = (relativelayout) findviewbyid(r.id.adoptview);         relativelayout.layoutparams lp = new relativelayout.layoutparams(                 relativelayout.layoutparams.wrap_content,                 relativelayout.layoutparams.wrap_content);         lp.addrule(relativelayout.below, r.id.adoptview);         lp.addrule(relativelayout.align_parent_left);         rl.addview(img, lp);     } } 

the main problem have, within addimage method...

have tried using method specific view? try parentview.findviewbyid()


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

node.js - Express and Redis - If session exists for this user, don't allow access -

excel - I can't get the attachement of the email PHP -