我的Activity中有幾個fragment。我想要在這個Activity中訪問在其中一個fragment創建的函數
Fragment:
public class RandomFragment extends Fragment {
public void randomfuntion (){
}
}
Activity:
public class Main extends FragmentActivity{
Fragment randomname;
public void anotherrandomfuntion (){
randomname. // I want to have access to randomfuntion
}
}
很簡單
(RandomFragment)randomname.randomfuntion()
應該就能解決了