2013-12-11 18 views
0

如何將兩個片段並排顯示?在動作條上單擊標籤時並排顯示兩個片段

我試過FragmentTransaction.replace(R.id.fragmentcontainer, myFragment), 其中myFragment擴充了一個包含引用其他片段類的兩個片段的佈局。

但是這給了我一個錯誤,說"myFragment cannot be cast to android.support.v4.app.Fragment

任何幫助,將不勝感激

回答

0

檢查import語句

替換這些語句

import android.app.Fragment; 
import android.app.FragmentManager; 
import android.app.FragmentTransaction; 

與這些陳述

import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentTransaction