开发者

How to instance an ImageView from a class?

Sorry for bugging you again, but how do I instance an ImageView ( or any other layout element ) from a class?

For example, in Activity I can simply write ImageView iv = new ImageView(this); , bu开发者_StackOverflow中文版t what should I place instead of "this" if I'm instancing it from a class?

Thanks!


Eventually you'd place your view in an activity, right?

So you could pass the Activity instance as an object when creating the view.

class YourClass {

 void createView(Activity activity) {

         ImageView iv = new ImageView(activity);



  }  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜