Skip to content

Commit 51a0100

Browse files
committed
demo修改
1 parent b533026 commit 51a0100

5 files changed

Lines changed: 25 additions & 48 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ picker.setSelectedIndex(...);
104104
```java
105105
picker.setUseWeight(true);
106106
```
107+
设置触摸弹窗外面是否自动关闭
108+
```java
109+
picker.setCanceledOnTouchOutside(...);
110+
```
107111
设置分隔线配置项,设置null将隐藏分割线及阴影
108112
```java
109113
picker.setDividerConfig(...);

‎app/src/main/java/cn/qqtheme/androidpicker/MyPickerApp.java‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@
66
import cn.qqtheme.framework.util.LogUtils;
77

88
/**
9-
* ***********************************************
10-
* ** ┏┓ ┏┓ **
11-
* ** ┏┛┻━━━┛┻┓ **
12-
* ** ┃ ┃ **
13-
* ** ┃ ━ ┃ **
14-
* ** ┃ ┳┛ ┗┳ ┃ **
15-
* ** ┃ ┃ **
16-
* ** ┃ ┻ ┃ **
17-
* ** ┃ ┃ **
18-
* ** ┗━┓ ┏━┛ **
19-
* ** ┃ ┃ **
20-
* ** ┃ ┃ **
21-
* ** ┃ ┗━━━┓ **
22-
* ** ┃ ┣┓ **
23-
* ** ┃ ┏┛ **
24-
* ** ┗┓┓┏━┳┓┏┛ **
25-
* ** ┃┫┫ ┃┫┫ **
26-
* ** ┗┻┛ ┗┻┛ **
27-
* ***********************************************
28-
* ** 神兽助我 扬我神威 **
29-
* ***********************************************
309
* Author:李玉江[QQ:1032694760]
3110
* DateTime:2016/7/20 20:28
3211
* Builder:Android Studio

‎app/src/main/java/cn/qqtheme/androidpicker/NestActivity.java‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* Builder:Android Studio
2020
*/
2121
public class NestActivity extends BaseActivity {
22-
private CarNumberPicker picker;
2322

2423
@Override
2524
protected View getContentView() {
@@ -28,6 +27,13 @@ protected View getContentView() {
2827

2928
@Override
3029
protected void setContentViewAfter(View contentView) {
30+
findViewById(R.id.nest_back).setOnClickListener(new View.OnClickListener() {
31+
@Override
32+
public void onClick(View v) {
33+
finish();
34+
}
35+
});
36+
3137
final TextView textView = findView(R.id.wheelview_tips);
3238
WheelView wheelView = findView(R.id.wheelview_single);
3339
final String[] strings = {"少数民族", "贵州穿青人", "不在56个少数民族之列", "第57个民族"};
@@ -47,7 +53,7 @@ public void onSelected(int index) {
4753
}
4854
});
4955

50-
picker = new CarNumberPicker(this);
56+
final CarNumberPicker picker = new CarNumberPicker(this);
5157
picker.setOffset(3);
5258
picker.setOnWheelLinkageListener(new LinkagePicker.OnWheelLinkageListener() {
5359
@Override
@@ -56,20 +62,9 @@ public void onLinkage(int firstIndex, int secondIndex, int thirdIndex) {
5662
}
5763
});
5864
ViewGroup viewGroup = findView(R.id.wheelview_container);
59-
viewGroup.addView(picker.getContentView());
60-
61-
findViewById(R.id.nest_back).setOnClickListener(new View.OnClickListener() {
62-
@Override
63-
public void onClick(View v) {
64-
finish();
65-
}
66-
});
67-
findViewById(R.id.nest_carnumber).setOnClickListener(new View.OnClickListener() {
68-
@Override
69-
public void onClick(View v) {
70-
picker.show();
71-
}
72-
});
65+
//得到选择器视图,可内嵌到其他视图容器,不需要调用show方法
66+
View pickerContentView = picker.getContentView();
67+
viewGroup.addView(pickerContentView);
7368
}
7469

7570
}

‎app/src/main/res/layout/activity_nest.xml‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
android:text="内嵌选择器"
3333
android:textColor="@android:color/white" />
3434

35-
<TextView
36-
android:id="@+id/nest_carnumber"
37-
style="?android:textAppearanceMedium"
38-
android:layout_width="wrap_content"
39-
android:layout_height="match_parent"
40-
android:gravity="center_vertical"
41-
android:text="车牌"
42-
android:textColor="@android:color/white" />
43-
4435
</LinearLayout>
4536

4637
<LinearLayout
@@ -65,9 +56,11 @@
6556

6657
<LinearLayout
6758
android:id="@+id/wheelview_container"
68-
android:layout_width="match_parent"
69-
android:layout_height="match_parent"
59+
android:layout_width="180dp"
60+
android:layout_height="200dp"
7061
android:layout_gravity="center"
62+
android:layout_marginTop="20dp"
63+
android:background="#FFF3F3F3"
7164
android:gravity="center"
7265
android:orientation="horizontal" />
7366

‎library/Common/src/main/java/cn/qqtheme/framework/popup/ConfirmPopup.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.text.TextUtils;
1111
import android.view.Gravity;
1212
import android.view.View;
13+
import android.view.ViewGroup;
1314
import android.widget.LinearLayout;
1415
import android.widget.RelativeLayout;
1516
import android.widget.TextView;
@@ -306,6 +307,11 @@ protected final View makeContentView() {
306307
tb = ConvertUtils.toPx(activity, contentTopAndBottomPadding);
307308
}
308309
centerView.setPadding(lr, tb, lr, tb);
310+
ViewGroup vg = (ViewGroup) centerView.getParent();
311+
if (vg != null) {
312+
//IllegalStateException: The specified child already has a parent
313+
vg.removeView(centerView);
314+
}
309315
rootLayout.addView(centerView, new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
310316
View footerView = makeFooterView();
311317
if (footerView != null) {

0 commit comments

Comments
 (0)