-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
ComplexActivity.java
60 lines (52 loc) · 1.88 KB
/
ComplexActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.xuexiang.xpagedemo;
import android.os.Bundle;
import android.view.View;
import com.xuexiang.xpage.base.XPageActivity;
import com.xuexiang.xpagedemo.databinding.ActivityComplexBinding;
import com.xuexiang.xpagedemo.fragment.TabAFragment;
import com.xuexiang.xpagedemo.fragment.TabBFragment;
import com.xuexiang.xutil.tip.ToastUtils;
/**
* @author xuexiang
* @since 2018/5/30 下午5:41
*/
public class ComplexActivity extends XPageActivity implements View.OnClickListener {
ActivityComplexBinding binding;
@Override
protected View getCustomRootView() {
binding = ActivityComplexBinding.inflate(getLayoutInflater());
return binding.getRoot();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding.btn1.setOnClickListener(this);
binding.btn2.setOnClickListener(this);
binding.btn3.setOnClickListener(this);
binding.btn4.setOnClickListener(this);
changePage(TabAFragment.class, null);
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.btn_1) {
changePage(TabAFragment.class, null);
} else if (id == R.id.btn_2) {
changePage(TabBFragment.class, null);
} else if (id == R.id.btn_3) {
TabAFragment tabAFragment = getPage(TabAFragment.class);
if (tabAFragment != null) {
ToastUtils.toast(tabAFragment.getData());
} else {
ToastUtils.toast("页面还未加载!");
}
} else if (id == R.id.btn_4) {
TabBFragment tabBFragment = getPage(TabBFragment.class);
if (tabBFragment != null) {
ToastUtils.toast(tabBFragment.getData());
} else {
ToastUtils.toast("页面还未加载!");
}
}
}
}