如果你使用“import android.app.Fragment;”然后使用:
1)ExampleFragment fragment = (ExampleFragment) getFragmentManager().findFragmentById(R.id.example_fragment); fragment.specific_function_name();
其中R.id.example_fragment最有可能是xml布局中的FrameLayout id。要么
2)ExampleFragment fragment = (ExampleFragment) getFragmentManager().findFragmentByTag(“FragTagName”); fragment.specific_function_name();
其中FragTagName是你指定的名字:TabHost mTabHost.newTabSpec(“FragTagName”)
如果您使用“import android.support.v4.app.Fragment;”然后使用以下任一方法:
1)ExampleFragment fragment = (ExampleFragment) getSupportFragmentManager().findFragmentById(R.id.example_fragment); fragment.specific_function_name();
要么
2)ExampleFragment fragment = (ExampleFragment) getSupportFragmentManager().findFragmentByTag(“FragTagName”); fragment.specific_function_name();