0
當我嘗試在我的ActionBar
中加載我的Fragment
時出現此錯誤。沒有找到ID爲0x7f070000的片段
引起:java.lang.IllegalArgumentException異常:未發現ID 0x7f070000爲片段HomeFragment視圖{4100e030#0的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);
}
}
的下面是我mainActivity
@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);
}
MainActivity 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>
我已使用onCreate方法更新了我的帖子 – theJava 2013-03-22 07:13:45
請粘貼mainActivity佈局XML – dmnlk 2013-03-22 07:21:31
我已更新佈局代碼。 – theJava 2013-03-22 07:29:24