Skip to content

Commit bed390b

Browse files
committed
加入选择器
1 parent 4ef4cbd commit bed390b

File tree

9 files changed

+820
-75
lines changed

9 files changed

+820
-75
lines changed

app/src/main/java/org/yh/yhframe/TwoFragment.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
import org.yh.library.ui.YHViewInject;
1313
import org.yh.library.utils.Constants;
1414
import org.yh.library.utils.LogUtils;
15+
import org.yh.library.view.YHLabelsView;
1516
import org.yh.yhframe.base.BaseFragment;
1617

18+
import java.util.ArrayList;
1719
import java.util.List;
1820

1921
public class TwoFragment extends BaseFragment
2022
{
2123
@BindView(id = R.id.two_txt, click = true)
2224
TextView two_txt;
23-
25+
@BindView(id = R.id.labels, click = true)
26+
private YHLabelsView labelsView;
2427
@Override
2528
protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle)
2629
{
@@ -42,6 +45,31 @@ public void onChange()
4245
LogUtils.e(TAG, "TwoFragment onChange()");
4346
}
4447

48+
@Override
49+
protected void initWidget(View parentView)
50+
{
51+
super.initWidget(parentView);
52+
//测试的数据
53+
ArrayList<String> label = new ArrayList<>();
54+
label.add("周一");
55+
label.add("周二");
56+
label.add("周三");
57+
label.add("周四");
58+
label.add("周五");
59+
label.add("周六");
60+
label.add("周日");
61+
labelsView.setLabels(label);
62+
labelsView.setSelectType(YHLabelsView.SelectType.MULTI);
63+
labelsView.setMaxSelect(0);
64+
labelsView.setOnLabelClickListener(new YHLabelsView.OnLabelClickListener() {
65+
@Override
66+
public void onLabelClick(View label, String labelText, int position) {
67+
YHViewInject.create().showTips(position + " : " + labelText);
68+
LogUtils.e(TAG,labelsView.getSelectLabels());
69+
}
70+
});
71+
}
72+
4573
@Override
4674
protected void widgetClick(View v)
4775
{
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!--<shape xmlns:android="http://schemas.android.com/apk/res/android">--><!--<stroke--><!--android:width="1dp"--><!--android:color="@color/divider_color" />--><!--<solid android:color="@color/pink_color" />--><!--<corners android:radius="4dp" />--><!--</shape>-->
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<!-- 标签选中时的背景 -->
4+
<item android:state_selected="true">
5+
<shape>
6+
<stroke android:width="2dp" android:color="#fb435b" />
7+
<corners android:radius="8dp" />
8+
<solid android:color="@android:color/white" />
9+
</shape>
10+
</item>
11+
<!-- 标签的正常背景 -->
12+
<item>
13+
<shape>
14+
<stroke android:width="2dp" android:color="#656565" />
15+
<corners android:radius="8dp" />
16+
<solid android:color="@android:color/white" />
17+
</shape>
18+
</item>
19+
</selector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<!-- 标签选中时的文字颜色 -->
4+
<item android:color="#fb435b" android:state_selected="true" />
5+
<!-- 标签的正常文字颜色 -->
6+
<item android:color="#2d2b2b" />
7+
</selector>

app/src/main/res/layout/fragment_one.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
android:layout_marginLeft="15dp"
2525
android:layout_marginRight="15dp"
2626
android:layout_marginTop="15dp"
27+
myline:axesWidth="2dp"
2728
myline:lineColor="#FF0000"
2829
myline:textColor="#ABABAB"
29-
myline:axesWidth="2dp"
3030
myline:textSize="12sp"/>
31+
3132
</FrameLayout>

app/src/main/res/layout/fragment_two.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,23 @@
1414
android:gravity="center"
1515
android:text="@string/two_fragment"
1616
android:textSize="30sp"/>
17-
17+
<org.yh.library.view.YHLabelsView
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
android:id="@+id/labels"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:layout_marginTop="10dp"
23+
android:minHeight="25dp"
24+
android:padding="5dp"
25+
app:labelBackground="@drawable/label_bg"
26+
app:labelTextColor="@drawable/label_text_color"
27+
app:labelTextPaddingBottom="5dp"
28+
app:labelTextPaddingLeft="10dp"
29+
app:labelTextPaddingRight="10dp"
30+
app:labelTextPaddingTop="5dp"
31+
app:labelTextSize="14sp"
32+
app:lineMargin="10dp"
33+
app:maxSelect="0"
34+
app:selectType="SINGLE"
35+
app:wordMargin="10dp"/>
1836
</FrameLayout>

yhlibrary/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ publish{
6666
userOrg = 'androidcoco'//https://bintray.com用户名
6767
groupId = 'org.yh.yhframe'//jcenter上的路径
6868
artifactId = 'YhLibraryForAndroid'//项目名称
69-
publishVersion = '1.0.14'//版本号
69+
publishVersion = '1.0.15'//版本号
7070
desc = 'Android实用框架采用MVC设计模式,多个项目经验总结,持续完善中'//描述,不重要
7171
website = siteUrl//项目主页
7272
}

0 commit comments

Comments
 (0)