0
嗨我使用Caldroid日曆,並且我只使用官方網站的初始化代碼,我使用getFragmentManager()
而不是getSupportFragmentManager()
,因爲我使用的代碼擴展自Fragment not Activity。 MysTab是TabbedActivity的片段。結果我有兩個日曆,我不知道爲什麼。有任何想法嗎?安卓日曆(caldroid)創建2日曆視圖
截圖
public class MysTab extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.logs_tab, container, false);
CaldroidFragment caldroidFragment = new CaldroidFragment();
Bundle args = new Bundle();
Calendar cal = Calendar.getInstance();
args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
caldroidFragment.setArguments(args);
FragmentTransaction t = getFragmentManager().beginTransaction();
t.replace(R.id.caldroidCal, caldroidFragment);
t.commit();
return rootView;
}
}
佈局:
<LinearLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<fragment
android:id="@+id/caldroidCal"
android:name="com.roomorama.caldroid.CaldroidFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</LinearLayout>
非常感謝:) – Aligator