当前位置:网站首页>Function and usage of numberpick
Function and usage of numberpick
2022-07-07 17:36:00 【XLMN】
Numberpick The function and usage of
Value selector , It is used for users to enter values , You can enter values through the keyboard , You can also drag to select values
public class MainActivity extends Activity {
NumberPicker np1, np2;
// Define the minimum value , Initial value of maximum value
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);
// Set up np1 The current value of the
np1.setValue(minfraction);
// Add listener
np1.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
// When numberPICKET When things change , Will stimulate the method
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
np2 = findViewById(R.id.numberpicket01);
np2.setMinValue(145);
np2.setMaxValue(150);
// set currency
np2.setValue(maxfraction);
// Add listener
np2.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
minfraction = newVal;
showSelectedPrice();
}
});
}
private void showSelectedPrice() {
Toast.makeText(this, " Your lowest score in a single subject is " + minfraction + " Your highest score in a single subject is " + 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=" Minimum score of single subject " />
<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=" The maximum score of a single subject "></TextView>
<NumberPicker
android:id="@+id/numberpicket01"
android:layout_width="match_parent"
android:layout_height="150dp"
android:focusable="true"
android:focusableInTouchMode="true" />
</TableRow>

边栏推荐
- PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
- SlashData开发者工具榜首等你而定!!!
- 电脑无法加域,ping域名显示为公网IP,这是什么问题?怎么解决?
- LeetCode刷题day49
- The top of slashdata developer tool is up to you!!!
- Jenkins发布uniapp开发的H5遇到的问题
- 专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
- With the latest Alibaba P7 technology system, mom doesn't have to worry about me looking for a job anymore
- Notes on installing MySQL in centos7
- Numberpick的功能和用法
猜你喜欢
随机推荐
本周小贴士#140:常量:安全习语
第3章业务功能开发(安全退出)
【可信计算】第十三次课:TPM扩展授权与密钥管理
本周小贴士#135:测试约定而不是实现
TabHOST 选项卡的功能和用法
LeetCode1051(C#)
【TPM2.0原理及应用指南】 12、13、14章
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
Repair method of firewall system crash and file loss, material cost 0 yuan
管理VDI的几个最佳实践
actionBar 导航栏学习
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
麒麟信安中标国网新一代调度项目!
【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
Solidity 开发环境搭建
MySQL usage notes 1
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
第2章搭建CRM项目开发环境(数据库设计)
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
【信息安全法律法規】複習篇









