Fragment에서 일종의 변환을 시도하고 있으며 FragmentActivity를 작성하기 위해 Eclipse에서 기본 애플리케이션 해골을 사용하고 있습니다. xml에서 사용자 지정 트랜지션 애니메이션을 지정하는 다른 게시물을 발견했지만 Transaction에서는이 작업이 수행되고 있으며 FragmentActivity를 사용하는 것은 없습니다. (btw 훨씬 쉬워집니다.)FragmentActivity 사용자 정의 단편 전환
FragmentActivity에서 사용자 지정 전환을 만드는 방법을 알고 싶습니다. 미리 감사드립니다.
편집 : F과 유사하지만 FragmentActivity와 같습니다.
MusicPlayerActivity.java
public class MusicPlayerActivity extends FragmentActivity {
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init pager and set its adapter
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
//other init code ...
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new MainFragment();
case 1:
return new AllSongsFragment();
case 2:
return new SettingsFragment();
default:
return null;
}
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
/**
* Get title for supplied Fragment number.
*/
@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
}
return null;
}
}
//other methods
}
activity_music_player.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MusicPlayerActivity$OptionsFragment" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MusicPlayerActivity" >
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
<ListView
android:id="@+id/drawer"
android:layout_width="160dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#333333"
android:choiceMode="singleChoice" />
조각 사이에서 '전환'중이지만 이벤트에서 조각 트랜잭션을 사용하지 않는 경우, 이는 사용자가 'ViewPager'및 'FragmentAdapter'를 사용한다고 가정합니다. ? 일부 코드 + 레이아웃을 게시 할 수 있습니까 –
그래, 난 ViewPager btw를 사용하고 있습니다. – Dejan