Skip to content

Commit

Permalink
demo修改
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Sep 1, 2017
1 parent b533026 commit 51a0100
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 48 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ picker.setSelectedIndex(...);
```java
picker.setUseWeight(true);
```
设置触摸弹窗外面是否自动关闭
```java
picker.setCanceledOnTouchOutside(...);
```
设置分隔线配置项,设置null将隐藏分割线及阴影
```java
picker.setDividerConfig(...);
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/java/cn/qqtheme/androidpicker/MyPickerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,6 @@
import cn.qqtheme.framework.util.LogUtils;

/**
* ***********************************************
* ** ┏┓ ┏┓ **
* ** ┏┛┻━━━┛┻┓ **
* ** ┃ ┃ **
* ** ┃ ━ ┃ **
* ** ┃ ┳┛ ┗┳ ┃ **
* ** ┃ ┃ **
* ** ┃ ┻ ┃ **
* ** ┃ ┃ **
* ** ┗━┓ ┏━┛ **
* ** ┃ ┃ **
* ** ┃ ┃ **
* ** ┃ ┗━━━┓ **
* ** ┃ ┣┓ **
* ** ┃ ┏┛ **
* ** ┗┓┓┏━┳┓┏┛ **
* ** ┃┫┫ ┃┫┫ **
* ** ┗┻┛ ┗┻┛ **
* ***********************************************
* ** 神兽助我 扬我神威 **
* ***********************************************
* Author:李玉江[QQ:1032694760]
* DateTime:2016/7/20 20:28
* Builder:Android Studio
Expand Down
27 changes: 11 additions & 16 deletions app/src/main/java/cn/qqtheme/androidpicker/NestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Builder:Android Studio
*/
public class NestActivity extends BaseActivity {
private CarNumberPicker picker;

@Override
protected View getContentView() {
Expand All @@ -28,6 +27,13 @@ protected View getContentView() {

@Override
protected void setContentViewAfter(View contentView) {
findViewById(R.id.nest_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

final TextView textView = findView(R.id.wheelview_tips);
WheelView wheelView = findView(R.id.wheelview_single);
final String[] strings = {"少数民族", "贵州穿青人", "不在56个少数民族之列", "第57个民族"};
Expand All @@ -47,7 +53,7 @@ public void onSelected(int index) {
}
});

picker = new CarNumberPicker(this);
final CarNumberPicker picker = new CarNumberPicker(this);
picker.setOffset(3);
picker.setOnWheelLinkageListener(new LinkagePicker.OnWheelLinkageListener() {
@Override
Expand All @@ -56,20 +62,9 @@ public void onLinkage(int firstIndex, int secondIndex, int thirdIndex) {
}
});
ViewGroup viewGroup = findView(R.id.wheelview_container);
viewGroup.addView(picker.getContentView());

findViewById(R.id.nest_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
findViewById(R.id.nest_carnumber).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
picker.show();
}
});
//得到选择器视图,可内嵌到其他视图容器,不需要调用show方法
View pickerContentView = picker.getContentView();
viewGroup.addView(pickerContentView);
}

}
15 changes: 4 additions & 11 deletions app/src/main/res/layout/activity_nest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@
android:text="内嵌选择器"
android:textColor="@android:color/white" />

<TextView
android:id="@+id/nest_carnumber"
style="?android:textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="车牌"
android:textColor="@android:color/white" />

</LinearLayout>

<LinearLayout
Expand All @@ -65,9 +56,11 @@

<LinearLayout
android:id="@+id/wheelview_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="180dp"
android:layout_height="200dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:background="#FFF3F3F3"
android:gravity="center"
android:orientation="horizontal" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -306,6 +307,11 @@ protected final View makeContentView() {
tb = ConvertUtils.toPx(activity, contentTopAndBottomPadding);
}
centerView.setPadding(lr, tb, lr, tb);
ViewGroup vg = (ViewGroup) centerView.getParent();
if (vg != null) {
//IllegalStateException: The specified child already has a parent
vg.removeView(centerView);
}
rootLayout.addView(centerView, new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
View footerView = makeFooterView();
if (footerView != null) {
Expand Down

0 comments on commit 51a0100

Please sign in to comment.