当前位置:网站首页>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)
- Number of exchanges in the 9th Blue Bridge Cup finals
- 【饭谈】如何设计好一款测试平台?
- Smart logistics platform: make overseas warehouses smarter
- [image sensor] correlated double sampling CDs
- User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
- 第3章业务功能开发(用户登录)
- Sator launched Web3 game "satorspace" and launched hoobi
猜你喜欢
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
如何在博客中添加Aplayer音乐播放器
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
【TPM2.0原理及应用指南】 1-3章
【网络攻防原理与技术】第6章:特洛伊木马
SlashData开发者工具榜首等你而定!!!
【可信计算】第十二次课:TPM授权与会话
【TPM2.0原理及应用指南】 16、17、18章
【可信计算】第十三次课:TPM扩展授权与密钥管理
How to add aplayer music player in blog
随机推荐
如何在软件研发阶段落地安全实践
第2章搭建CRM项目开发环境(搭建开发环境)
【网络攻防原理与技术】第3章:网络侦察技术
[Seaborn] combination chart: pairplot and jointplot
L1-023 输出GPLT(Lua)
SlashData开发者工具榜首等你而定!!!
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
99% of users often make mistakes in power Bi cloud reports
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
Flask搭建api服务
Proxmox VE重装后,如何无损挂载原有的数据盘?
本周小贴士#134:make_unique与私有构造函数
【TPM2.0原理及应用指南】 5、7、8章
状态模式 - Unity(有限状态机)
Sator launched Web3 game "satorspace" and launched hoobi
大笨钟(Lua)
麒麟信安操作系统衍生产品解决方案 | 存储多路径管理系统,有效提高数据传输可靠性
How to add aplayer music player in blog
电脑无法加域,ping域名显示为公网IP,这是什么问题?怎么解决?
L1-027 出租(Lua)