我有TabHost
FragmentActivity
(SherlockFragmentActivity
)。
如何获取标签(Fragment
){来自View
的{1}}?当然,没有FragmentActivity
方式。
我的FragmentActivity代码
static
答案 0 :(得分:0)
内部活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
Fragment yourFragment = new YourFragment();
//put fragment to activity
//YOUR_FRAGMENT_ID is "@+id/" tag for fragment in your_activity.xml
getSupportFragmentManager().beginTransaction().replace(R.id.YOUR_FRAGMENT_ID, yourFragment).commit();
getSupportFragmentManager().executePendingTransactions();
//get reference to fragment
Fragment refToYourFragment = (Fragment) getSupportFragmentManager().findFragmentById(YOUR_FRAGMENT_ID);
}