-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加XPageActivity构建方法,方便自定义Fragment的容器
- Loading branch information
1 parent
5b2bf9c
commit 8d472c0
Showing
7 changed files
with
229 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/xuexiang/xpagedemo/ComplexActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.xuexiang.xpagedemo; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.xuexiang.xpage.base.XPageActivity; | ||
import com.xuexiang.xpage.enums.CoreAnim; | ||
import com.xuexiang.xpagedemo.fragment.DateReceiveFragment; | ||
import com.xuexiang.xpagedemo.fragment.TestFragment; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
|
||
/** | ||
* @author xuexiang | ||
* @since 2018/5/30 下午5:41 | ||
*/ | ||
public class ComplexActivity extends XPageActivity { | ||
|
||
@BindView(R.id.btn_1) | ||
Button btn1; | ||
@BindView(R.id.btn_2) | ||
Button btn2; | ||
|
||
@Override | ||
protected int getLayoutId() { | ||
return R.layout.activity_complex; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
ButterKnife.bind(this); | ||
openPage(TestFragment.PAGE_NAME, null, CoreAnim.none); | ||
} | ||
|
||
|
||
@OnClick({R.id.btn_1, R.id.btn_2}) | ||
public void onViewClicked(View view) { | ||
switch (view.getId()) { | ||
case R.id.btn_1: | ||
changePage(TestFragment.PAGE_NAME, null, CoreAnim.none); | ||
break; | ||
case R.id.btn_2: | ||
Bundle params = new Bundle(); | ||
params.putBoolean(DateReceiveFragment.KEY_IS_NEED_BACK, false); | ||
int id = (int) (Math.random() * 100); | ||
params.putString(DateReceiveFragment.KEY_EVENT_NAME, "事件" + id); | ||
params.putString(DateReceiveFragment.KEY_EVENT_DATA, "事件" + id + "携带的数据"); | ||
changePage("数据接收", params, CoreAnim.none); | ||
break; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/xuexiang/xpagedemo/fragment/ComplexPageFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.xuexiang.xpagedemo.fragment; | ||
|
||
import android.content.Intent; | ||
|
||
import com.xuexiang.xpage.annotation.Page; | ||
import com.xuexiang.xpage.base.XPageSimpleListFragment; | ||
import com.xuexiang.xpagedemo.ComplexActivity; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author xuexiang | ||
* @since 2018/5/30 下午6:11 | ||
*/ | ||
@Page(name = "复杂使用") | ||
public class ComplexPageFragment extends XPageSimpleListFragment { | ||
/** | ||
* 初始化例子 | ||
* | ||
* @param lists | ||
* @return | ||
*/ | ||
@Override | ||
protected List<String> initSimpleData(List<String> lists) { | ||
lists.add("复杂页面使用"); | ||
return lists; | ||
} | ||
|
||
/** | ||
* 条目点击 | ||
* | ||
* @param position | ||
*/ | ||
@Override | ||
protected void onItemClick(int position) { | ||
switch(position) { | ||
case 0: | ||
startActivity(new Intent(getContext(), ComplexActivity.class)); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:id="@+id/btn_1" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="启动A界面" /> | ||
|
||
<Button | ||
android:id="@+id/btn_2" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:text="启动B界面" /> | ||
|
||
</LinearLayout> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="2dp" | ||
android:background="@android:color/darker_gray"/> | ||
|
||
<FrameLayout | ||
android:id="@id/fragment_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="400dp"> | ||
|
||
</FrameLayout> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="2dp" | ||
android:background="@android:color/darker_gray"/> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:text="这里是底部" | ||
android:textSize="18sp" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters