当前位置:网站首页>Numberpick的功能和用法
Numberpick的功能和用法
2022-07-07 15:40:00 【XLMN】
Numberpick的功能和用法
数值选择器,用于用户输入数值,可通过键盘输入数值,也可通过拖动来选择数值
public class MainActivity extends Activity {
NumberPicker np1, np2;
//定义最小值,最大值的初始值
int minfraction = 140, maxfraction = 150;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.numberpicket);
np1 = findViewById(R.id.numberpicket);
np1.setMaxValue(150);
np1.setMinValue(140);
//设置np1的当前值
np1.setValue(minfraction);
//添加监听器
np1.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
//当numberPICKET发生改变的时候,会激发该方法
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
np2 = findViewById(R.id.numberpicket01);
np2.setMinValue(145);
np2.setMaxValue(150);
//设置当前值
np2.setValue(maxfraction);
//添加监听器
np2.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
}
private void showSelectedPrice() {
Toast.makeText(this, "你的单科最低分是" + minfraction + "你单科的最高分是" + maxfraction, Toast.LENGTH_LONG).show();
}
}
<?xml version="1.0" encoding="utf-8"?><TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="单科最小分数" />
<NumberPicker
android:id="@+id/numberpicket"
android:layout_width="match_parent"
android:layout_height="150dp"
android:focusable="true"
android:focusableInTouchMode="true" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="单科最大分数"></TextView>
<NumberPicker
android:id="@+id/numberpicket01"
android:layout_width="match_parent"
android:layout_height="150dp"
android:focusable="true"
android:focusableInTouchMode="true" />
</TableRow>
边栏推荐
- L1-023 输出GPLT(Lua)
- The mail server is listed in the blacklist. How to unblock it quickly?
- 本周小贴士#135:测试约定而不是实现
- 责任链模式 - Unity
- 国内首创!Todesk将RTC技术融入远程桌面,画质更清晰操作更流畅
- LeetCode 890(C#)
- The computer cannot add a domain, and the Ping domain name is displayed as the public IP. What is the problem? How to solve it?
- Jenkins发布uniapp开发的H5遇到的问题
- 【分布式理论】(一)分布式事务
- 本周小贴士#136:无序容器
猜你喜欢
让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
Matplotlib绘图界面设置
企业即时通讯软件是什么?它有哪些优势呢?
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
第2章搭建CRM项目开发环境(数据库设计)
mysql官网下载:Linux的mysql8.x版本(图文详解)
第3章业务功能开发(用户访问项目)
第3章业务功能开发(用户登录)
【视频/音频数据处理】上海道宁为您带来Elecard下载、试用、教程
随机推荐
状态模式 - Unity(有限状态机)
PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight
Solid function learning
麒麟信安携异构融合云金融信创解决方案亮相第十五届湖南地区金融科技交流会
麒麟信安加入宁夏商用密码协会
L1-023 输出GPLT(Lua)
百度地图自定义样式向右拖拽导致全球地图经度0度无法正常显示
第2章搭建CRM项目开发环境(搭建开发环境)
Biped robot controlled by Arduino
mysql官网下载:Linux的mysql8.x版本(图文详解)
SlashData开发者工具榜首等你而定!!!
What is cloud computing?
第2章搭建CRM项目开发环境(数据库设计)
大笨钟(Lua)
Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
L1-028 判断素数(Lua)
Flask搭建api服务-SQL配置文件
【网络攻防原理与技术】第7章:口令攻击技术 第8章:网络监听技术
99%的人都不知道|私有化部署还永久免费的即时通讯软件!