Reputation: 6527
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); , but what should I place instead of "this" if I'm instancing it from a class?
Thanks!
Upvotes: 0
Views: 648
Reputation: 5208
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);
} }
Upvotes: 2