当我尝试将 my 加载Fragment
到我的ActionBar
.
原因:java.lang.IllegalArgumentException:没有为片段 HomeFragment{4100e030 #0 id=0x7f070000} 找到 id 0x7f070000 的视图
public class HomeFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.home, container, false);
}
}
以下是我的主要活动
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prime_mobile_home);
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab homeTab = actionBar.newTab();
homeTab.setText("Home");
homeTab.setIcon(R.drawable.home);
Fragment homeFragment = new HomeFragment();
homeTab.setTabListener(new MyTabsListener(homeFragment));
actionBar.addTab(homeTab);
}
主活动 XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>