请教老师两个问题。一个是关于seekbar,另一个是关于toast信息有问题。
//Book类 public class Book { private String name; private boolean his,sus,lite; private int age; private int pic; public Book(){ } public Book(String name, boolean his, boolean sus, boolean lite, int age, int pic) { this.name = name; this.his = his; this.sus = sus; this.lite = lite; this.age = age; this.pic = pic; } public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean isHis() { return his; } public void setHis(boolean his) { this.his = his; } public boolean isSus() { return sus; } public void setSus(boolean sus) { this.sus = sus; } public boolean isLite() { return lite; } public void setLite(boolean lite) { this.lite = lite; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public int getPic(){ return pic; } public void setPic(int pic){ this.pic = pic; } @Override public String toString() { return "Book{" + "name='" + getName() + '\'' + ", his=" + isHis() + ", sus=" + isSus() + ", lite=" + isLite() + ", age=" + getAge() + ", pic=" + getPic() + '}'; } } /////////////////////////////////////////////////////////////////////////////////////////////// //Person类 public class Person { private String name; private String gender; private String time; Book book; public Person(){ } public Person(String name, String gender, String time, Book book) { this.name = name; this.gender = gender; this.time = time; this.book = book; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public Book getBook() { return book; } public void setBook(Book book) { this.book = book; } @Override public String toString() { return "Person{" + "name='" + getName() + '\'' + ", gender='" + getGender() + '\'' + ", time='" + getTime() + '\'' + ", book=" + book + '}'; } } ////////////////////////////////////////////////////////////////////////////////////////// //seekbar选择年龄 class seekListener implements SeekBar.OnSeekBarChangeListener{ @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { f_age = seekBar.getProgress(); tv_sb.setText(f_age+""); } } //////////////////////////////////////////////////////////////////////////////////////////// //点击查找和下一个 class buttonListener implements View.OnClickListener{ @Override public void onClick(View v) { switch (v.getId()){ case R.id.bt_find: books.clear(); count = 0; checkData(); //先进行符合条件的寻找 if(checkTime(et_time.getText().toString(),tv_time.getText().toString())){ Toast.makeText(MainActivity.this,"借书时间晚于归还时间!程序将退出!",Toast.LENGTH_SHORT).show(); finish(); }else{ if(books.size() == 0) { iv_book.setImageResource(R.drawable.f); name.setText("书名"); type.setText("类型"); age.setText("适用年龄"); Toast.makeText(MainActivity.this, "未找到任何书籍!请重新选择!", Toast.LENGTH_SHORT).show(); } else{ showPic(count); String n = name.getText().toString(); String t = et_time.getText().toString(); person.setName(n); person.setTime(t); Toast.makeText(MainActivity.this, "个人信息为:" + person, Toast.LENGTH_SHORT).show(); count++; } } break; case R.id.bt_next: //进行切换 if(count < books.size()) { showPic(count); String n = name.getText().toString(); String t = et_time.getText().toString(); person.setName(n); person.setTime(t); Toast.makeText(MainActivity.this, "个人信息为:" + person, Toast.LENGTH_SHORT).show(); count++; }else { Toast.makeText(MainActivity.this, "由于已经是最后一个书籍,从头显示!", Toast.LENGTH_SHORT).show(); count = 0; showPic(count); count++; } } } }
第一个是,我的seekbar还没到进度条最右边无法继续拖动;第二个是,toast个人信息时book显示null是为什么?
0
收起
正在回答
2回答
1、SeekBar如果设置其最小值就会出现拖不到底的情况,一般处理是使用其默认最小值0,然后在获取值后根据业务数据手动处理。
2、这里缺少setBook( book )设置书籍信息
相似问题
登录后可查看更多问答,登录/注册
Android零基础入门2018版
- 参与学习 人
- 提交作业 5461 份
- 解答问题 7238 个
此次推出的专题为Android攻城狮培养计划的第一部分语法与界面基础篇,将带大家从0开始学习Android开发。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星