Nishant Sambyal Nishant Sambyal - 3 years ago 154
Android Question

can i access resources or views of fragment inside its baseactivity

I have a base activity in which i have inflated 4 fragments.
i have several methods which i have to use in all the fragments.but i don't want that. I want to implement that method inside my base activity so that i can reuse my method to all the fragments.
I want to use onTouchListener event of every parent layout of fragments.
i can achieve this via xml onClick method and can call this method in baseActivity, But i want to use onTouch event, that method does't avalilable in layout xml. So i simply want to access resource from my fragment layout in my base activity and implement TouchEvent in baseActivity.

Is it Possible.??
Any help is Appreciated..Thanks!

Answer Source

if you make a one class called constant class into that declare your method as public static and using that class you can access this method to any activity and fragment, you have to pass argument context of your activity into that method.

may be this is helpful to you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download