I need to call the setContentView(int) from my main Activity from another class which does not extends Activity.
In my custom class I've got the private Context context;
var that is passed from the Activity in the Constructor but I can't figure out how to acces the Activity methods using the context
variable.
If your context is an instance of Activity class, simple class cast should work:
Activity a = (Activity) context;
a.setContentView(R.layout.your_layout);
One solution (may not be the most elegant) is to pass the calling activity to the other class, not just the context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With