请教老师两个问题。一个是关于seekbar,另一个是关于toast信息有问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | //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 份
- 解答问题 7235 个
此次推出的专题为Android攻城狮培养计划的第一部分语法与界面基础篇,将带大家从0开始学习Android开发。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧