SupportFragment
??
????Fragment??????Fragment??????????????????Fragment?Activity???????Fragment???????????????? ???????Activity+?Fragment???Activity+?Fragment???
????
- ??????Fragment????
- ?Fragment????????
- ?Fragment??OnBackPressed()????
- ??Fragment?Activity???????????????????
- ???“????”????????????
Demo??
Demo???????App?????????Activity+?Fragment???MVP+MVVM?????ARouter?????????????EventBus??????????? ??????demo???wiki?
????
?? | supportfragment |
---|---|
???? |
??
Maven??
<dependency>
<groupId>com.justkiddingbaby</groupId>
<artifactId>supportfragment</artifactId>
<version>????</version>
<type>pom</type> </dependency>
JCenter??
??? ???build.gradle???
repositories {
jcenter()
}
??? ?module?build.gradle???
compile 'com.justkiddingbaby:supportfragment:????'
??
?Activity????
Activity???? SupportActivity???int getFragmentContentId()??? ?????startFragment(SupportFragment)???????????????Activity???????
TestAvtivity.java
public class TestActivity extends SupportActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public int getFragmentContentId() {
return R.id.main_content;
}
}
main_content.xml
<?xml version="1.0" encoding="utf-8"?> <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainFrameContent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
?Fragment????
Fragment???? SupportFragment????????????Fragment???????
TestFragment.java
public class TestFragment extends SupportFragment {
}
Fragment?????????Fragment????????????SupportFragment
????
??? | ?? | ?? | ?? |
---|---|---|---|
int | getFragmentContentId() | ??Fragment????id??startFragment()??????? | Activity |
void | startFragment(SupportFragment) | ??getFragmentContentId()????????????Fragment | Activity/Fragment |
void | startFragmentForResult(SupportFragment,int) | ?startFragment?????????? | Activity/Fragment |
void | startFragmentForResult(SupportFragment,int,Bundle) | ?startFragment?????????? | Activity/Fragment |
void | setFragmentResult(int,Bundle) | ??Fragment???? | Activity/Fragment |
void | onFragmentResult(int,int,Bundle) | Fragment??????? | Activity/Fragment |
void | showFragment(SupportFragment,int) | ?int????Fragment?????contentId????Fragment???Fragment???? | Activity/Fragment |
void | hideFragment(SupportFragment,int) | ??Fragment??????Fragment???? | Activity/Fragment |
void | replaceFragment(SupportFragment,int) | ??int???Fragment??????Fragment???Fragment???? | Activity/Fragment |
void | showPopFragment() | ?????Fragment | Activity/Fragment |
void | closeCurrentAndShowPopFragment() | ????Fragment?????Fragment | Activity/Fragment |
void | clearFragment() | ??????Fragment | Activity/Fragment |
void | close() | ????Fragment??Activity | Activity/Fragment |
void | closeFragment(SupportFragment) | ????Fragment | Activity/Fragment |
String | getFragmentTAG() | ??Fragment?TAG????????????????????????TAG???????? | Fragment |
boolean | isContainChildFragment() | ????Activity/Fragment????Fragment | Activity/Fragment |
SupportFragment | getPopSupportFragment() | ?????SupportFragment,????null | Activity/Fragment |
boolean | isHideLashFragmentBeforeFinish() | Activity?finish??????????Fragment,???false | Activity |
?????????Activity??????Fragment????????????????????????????????? ?????Fragment?????????Fragment????????
????
v1.1.15(2017/8/5)
1???Fragment??onBackPressed()???,???Fragment? isHideLashFragmentBeforeFinish()
???false??????
v1.1.13(2017/8/16)
1??? isContainChildFragment()
???
2??? SupportFragment?onKeyDown
?????
3??? getPopSupportFragment()
???
4??? isHideLashFragmentBeforeFinish()
???
v1.1.7(2017/8/15)
1??SupportActivity/SupportFragment?? isSupportResumed()
????,????Activity????Resume???
v1.1.6(2017/8/10)
1??Fragment?? onKeyDown(int keyCode, KeyEvent event)
??????
v1.1.5(2017/6/29)
1?????supportFragment???allowBackup?????
v1.1.4(2017/5/19)
1?????????SDK???12
v1.1.3(2017/5/19)
1??????????????????
2?????v7??????SDK???
v1.1.2(2017/5/17)
1???Fragment???????Bundle??????
v1.1.1(2017/5/15)
1?????startFragmentForResult??????onFragmentResult?requestCode???????
v1.1.0(2017/5/15)
1???hideFragment(SupportFragment)???
2???startFragmentForResult?????????startActivityForResult?
v1.0.2(2017/5/8)
1???Support???????????????SupportTransaction????????
v1.0.1(2017/5/4)
1???Support????showFragment?????added??Fragment??showFragment??????
v1.0(2017/5/3)
1?SupportFragment?????????Fragment???
2?????????Demo????App?