Support
Quality
Security
License
Reuse
kandi has reviewed AndroidPicker and discovered the below as its top functions. This is intended to give you an instant insight into AndroidPicker implemented functionality, and help decide if they suit your requirements.
GitHub:https://github.com/gzu-liyujiang/AndroidPicker
码云(GitEE):https://gitee.com/li_yu_jiang/AndroidPicker
Demo:https://github.com/gzu-liyujiang/AndroidPicker/blob/master/demo.apk
依赖配置
allprojects {
repositories {
maven { url 'https://www.jitpack.io' }
}
}
在 Java 中
List<GoodsCategoryBean> data = new ArrayList<>();
data.add(new GoodsCategoryBean(1, "食品生鲜"));
data.add(new GoodsCategoryBean(2, "家用电器"));
data.add(new GoodsCategoryBean(3, "家居生活"));
data.add(new GoodsCategoryBean(4, "医疗保健"));
data.add(new GoodsCategoryBean(5, "酒水饮料"));
data.add(new GoodsCategoryBean(6, "图书音像"));
OptionPicker picker = new OptionPicker(this);
picker.setTitle("货物分类");
picker.setBodyWidth(140);
picker.setData(data);
picker.setDefaultPosition(2);
picker.setOnOptionPickedListener(this);
//OptionWheelLayout wheelLayout = picker.getWheelLayout();
//wheelLayout.setIndicatorEnabled(false);
//wheelLayout.setTextColor(0xFFFF00FF);
//wheelLayout.setSelectedTextColor(0xFFFF0000);
//wheelLayout.setTextSize(15 * view.getResources().getDisplayMetrics().scaledDensity);
//wheelLayout.setSelectedTextBold(true);
//wheelLayout.setCurtainEnabled(true);
//wheelLayout.setCurtainColor(0xEEFF0000);
//wheelLayout.setCurtainCorner(CurtainCorner.ALL);
//wheelLayout.setCurtainRadius(5 * view.getResources().getDisplayMetrics().density);
//wheelLayout.setOnOptionSelectedListener(new OnOptionSelectedListener() {
// @Override
// public void onOptionSelected(int position, Object item) {
// picker.getTitleView().setText(picker.getWheelView().formatItem(position));
// }
//});
picker.show();
在 XML 中
<com.github.gzuliyujiang.wheelview.widget.WheelView
android:id="@+id/wheel_view"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:wheel_atmosphericEnabled="true"
app:wheel_curvedEnabled="true"
app:wheel_curvedIndicatorSpace="4dp"
app:wheel_curvedMaxAngle="60"
app:wheel_indicatorColor="#FF0081FF"
app:wheel_itemSpace="50dp"
app:wheel_itemTextColor="#FF474747"
app:wheel_itemTextColorSelected="#FF0081FF"
app:wheel_itemTextSize="20sp" />
自定义样式(可选)
//4.0.0版本开始内置支持四种弹窗样式(Default、One、Two、Three),效果可运行Demo查看
public class DemoApp extends Application {
@Override
public void onCreate() {
super.onCreate();
DialogConfig.setDialogStyle(DialogStyle.Default);
DialogConfig.setDialogColor(new DialogColor()
.cancelTextColor(0xFF999999)
.okTextColor(0xFF0099CC));
}
}
3.0.0 之后
Copyright (c) 2020-2021 gzu-liyujiang <1032694760@qq.com>
The software is licensed under the Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
PURPOSE.
See the Mulan PSL v2 for more details.
3.0.0 之前
MIT License
Copyright (c) 穿青山魈人马<liyujiang_tk@yeah.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
AlertDialog not dismissing by tapping on background on Samsung devices
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setCanceledOnTouchOutside(true);
Can TimePicker be used without header on Android
private void hideTimeHeaderLayout(TimePicker picker) {
final int id = Resources.getSystem().getIdentifier("time_header", "id", "android");
final View timeLayout = picker.findViewById(id);
if(timeLayout != null) {
timeLayout .setVisibility(View.GONE);
}
}
QUESTION
AlertDialog not dismissing by tapping on background on Samsung devices
Asked 2018-Sep-08 at 00:34I am using AlertDialog
(full disclosure: using React Native, but this is using Native code and bridged through the Native Modules API so I don't think RN is causing the issue) in the app I develop for displaying a menu of items, which works perfectly in all cases. I developed it using the Pixel 2 simulator (API 28, Android 9). However, when testing on a Samsung device (Galaxy S4, Android 5), the dialog is not dismissable by touching the background of the app; I can only cancel it when pressing the back button. Here is the code I am using:
@ReactMethod
public void showDialog(ReadableArray labelsReadableArray, final Promise promise) {
final String[] labels = getLabels(labelsReadableArray);
new AlertDialog.Builder(getCurrentActivity())
.setItems(labels, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int itemIndex) {
dialog.dismiss();
promise.resolve(itemIndex);
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
promise.reject("dialog was closed");
}
}).setCancelable(true)
.show();
}
and in the React Native code I call:
NativeModules.AndroidPicker.showDialog(labels)
.then((index) => /* JS/redux action to process the change)
.catch(err => console.log(err))
Why is the Samsung device not cancelling the dialog when the background is tapped, while other Android phones do? How can I fix this?
ANSWER
Answered 2018-Sep-08 at 00:34You can use the following solution to dismiss the AlertDialog
by tapping on the background on Samsung devices:
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setCanceledOnTouchOutside(true);
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit