Click here to Skip to main content
15,888,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Suppose i have a actvity named "SearchActivity.java" which has a method dosearch().

there is fragment class named "fragment.java" and it is called from "MainActivity.java" class

can i call dosearch() method in fragment.java?

if possible how to call?

and i want to call this dosearch() method on click of a button in fragment.java class.

What I have tried:

i tried calling a method from a activity in fragment class of another activity..but did not work?
Posted
Updated 5-Oct-17 9:29am

1 solution

In order to call the dosearch() method from within the fragment class, you'd either need to make the dosearch() method static, or you would need a SearchActivity object.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900