测试

布局文件


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.act.ViewActivity">

 


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/img_bg"
android:orientation="horizontal">

<vip.zhuahilong.mydefineview.widget.CertificationProgress
android:id="@+id/certificationProgress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="10dp"
app:textColor="@color/white"
app:textSize="10dp" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">

<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="?actionBarSize"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<EditText
android:id="@+id/stepCountEdit"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:gravity="center"
android:hint="输入StepCount"/>

</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="?actionBarSize"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<EditText
android:id="@+id/nextStepEdit"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:gravity="center"
android:hint="输入NextStep"/>

</android.support.design.widget.TextInputLayout>

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_height="wrap_content">

<Button
android:id="@+id/stepCount"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_gravity="center_horizontal"
android:layout_height="?actionBarSize"
android:gravity="center"
android:text="stepCount"
android:textAllCaps="false"
android:textSize="18sp" />

<Button
android:id="@+id/nextStep"
android:layout_width="0dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_height="?actionBarSize"
android:gravity="center"
android:text="nextStep"
android:textAllCaps="false"
android:textSize="18sp" />
</LinearLayout>

</LinearLayout>

</RelativeLayout>

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
activity文件:


public class ViewActivity extends BaseActivity {

@BindView(R.id.certificationProgress)
CertificationProgress mCertificationProgress;
@BindView(R.id.nextStepEdit)
EditText nextStepEdit;
@BindView(R.id.stepCountEdit)
EditText stepCountEdit;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);

}

@OnClick({R.id.nextStep,R.id.stepCount})
public void clickMethod(View view) {
if (view.getId() == R.id.stepCount) {
String stepCountStr = stepCountEdit.getText().toString();
if (!TextUtils.isEmpty(stepCountStr)) {
try {
int sum = Integer.parseInt(stepCountStr);
List<String> stringList = new ArrayList<>();
for (int i = 1; i <= sum; i++) {
stringList.add("Step " + i + " ");
}
mCertificationProgress.setStepTextContent(stringList);
} catch (Exception e) {
new AlertDialog.Builder(this)
.setMessage(e.getMessage())
.show();
}
}

} else {
String nextStepStr = nextStepEdit.getText().toString();
if (!TextUtils.isEmpty(nextStepStr)) {
try {
mCertificationProgress.setStep(Integer.parseInt(nextStepStr));
} catch (Exception e) {
new AlertDialog.Builder(this)
.setMessage(e.getMessage())
.show();
}
}
}
}
}
--------------------- 

posted @ 2019-08-03 19:23  李艳艳665  阅读(63)  评论(0编辑  收藏  举报