14 changed files with 269 additions and 23 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
package cc.niushuai.dididone.ui.statistic; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.fragment.app.Fragment; |
||||
import androidx.fragment.app.FragmentManager; |
||||
import androidx.fragment.app.FragmentPagerAdapter; |
||||
|
||||
import java.util.List; |
||||
|
||||
import cc.niushuai.dididone.ui.statistic.charts.BaseChartFragment; |
||||
|
||||
public class MyPagerAdapter extends FragmentPagerAdapter { |
||||
List<BaseChartFragment> fragmentList; |
||||
|
||||
//构造方法,方便之后赋值调用
|
||||
public MyPagerAdapter(FragmentManager fm, List<BaseChartFragment> fragmentList){ |
||||
super(fm); |
||||
this.fragmentList = fragmentList; |
||||
} |
||||
|
||||
//根据Item的位置返回对应位置的Fragment,绑定item和Fragment
|
||||
@NonNull |
||||
@Override |
||||
public BaseChartFragment getItem(int position) { |
||||
return fragmentList.get(position); |
||||
} |
||||
|
||||
//设置item的数量
|
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return fragmentList.size(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package cc.niushuai.dididone.ui.statistic.charts; |
||||
|
||||
import cc.niushuai.dididone.ui.base.BaseFragment; |
||||
|
||||
public class BaseChartFragment extends BaseFragment { |
||||
|
||||
private String mTitle; |
||||
|
||||
public BaseChartFragment(String mTitle) { |
||||
this.mTitle = mTitle; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return mTitle; |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package cc.niushuai.dididone.ui.statistic.charts; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import cc.niushuai.dididone.R; |
||||
|
||||
public class ListFragment extends BaseChartFragment { |
||||
|
||||
|
||||
public ListFragment() { |
||||
super("列表视图"); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_stat_list, container, false); |
||||
return view; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package cc.niushuai.dididone.ui.statistic.charts; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import cc.niushuai.dididone.R; |
||||
|
||||
public class MonthFragment extends BaseChartFragment{ |
||||
|
||||
public MonthFragment() { |
||||
super("月视图"); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_stat_month, container, false); |
||||
return view; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package cc.niushuai.dididone.ui.statistic.charts; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import cc.niushuai.dididone.R; |
||||
|
||||
public class OtherFragment extends BaseChartFragment{ |
||||
|
||||
public OtherFragment() { |
||||
super("其他"); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_stat_other, container, false); |
||||
return view; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
package cc.niushuai.dididone.ui.statistic.charts; |
||||
|
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
|
||||
import cc.niushuai.dididone.R; |
||||
|
||||
public class WeekFragment extends BaseChartFragment { |
||||
|
||||
public WeekFragment() { |
||||
super("周视图"); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
View view = inflater.inflate(R.layout.fragment_stat_week, container, false); |
||||
return view; |
||||
} |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
<LinearLayout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_horizontal" |
||||
android:textSize="50sp" |
||||
android:text="list"/> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<?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"> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_horizontal" |
||||
android:textSize="50sp" |
||||
android:text="month"/> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<?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"> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_horizontal" |
||||
android:textSize="50sp" |
||||
android:text="other"/> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<?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"> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_horizontal" |
||||
android:textSize="50sp" |
||||
android:text="week"/> |
||||
|
||||
</LinearLayout> |
@ -1,22 +1,33 @@
@@ -1,22 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tl="http://schemas.android.com/apk/res-auto" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:context=".ui.statistic.StatisticFragment"> |
||||
android:orientation="vertical"> |
||||
|
||||
<TextView |
||||
android:id="@+id/text_gallery" |
||||
<!-- stat_tab_layout --> |
||||
<com.flyco.tablayout.SlidingTabLayout |
||||
android:id="@+id/stat_tab_layout" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:textAlignment="center" |
||||
android:textSize="20sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
android:layout_height="48dp" |
||||
android:background="#EEEEEE" |
||||
tl:tl_divider_color="#1A000000" |
||||
tl:tl_divider_padding="13dp" |
||||
tl:tl_divider_width="1dp" |
||||
tl:tl_indicator_color="#000000" |
||||
tl:tl_indicator_height="1.5dp" |
||||
tl:tl_indicator_width_equal_title="true" |
||||
tl:tl_tab_padding="22dp" |
||||
tl:tl_tab_space_equal="true" |
||||
tl:tl_textBold="SELECT" |
||||
tl:tl_textSelectColor="@color/red" |
||||
tl:tl_textUnselectColor="@color/gray_light_less" |
||||
tl:tl_underline_height="2dp" /> |
||||
|
||||
<androidx.viewpager.widget.ViewPager |
||||
android:id="@+id/stat_viewpager" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0px" |
||||
android:layout_weight="1" |
||||
android:background="@android:color/white" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue