20260213
终于把安卓端的写完了,年后看一看Kotlin和TS,把语言升级一下,然后就看看compose,这样下学期的安卓课程就差不多了吧...
依旧展示代码环节:
上次写了home,login和register,这次展示一下userInfo,test和report。
activity_user_info.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical" 7 android:background="#F5F5F5"> 8 9 <TextView 10 android:layout_width="match_parent" 11 android:layout_height="60dp" 12 android:background="#03A9F4" 13 android:gravity="center" 14 android:text="@string/SystemTitle" 15 android:textColor="#FFFFFF" 16 android:textSize="30sp"/> 17 18 <TextView 19 android:layout_width="match_parent" 20 android:layout_height="30dp" 21 android:text="@string/userInfo" 22 android:background="#03A9D4" 23 android:gravity="center_vertical" 24 android:paddingLeft="10dp"/> 25 26 <ScrollView 27 android:layout_width="match_parent" 28 android:layout_height="match_parent" 29 android:padding="16dp"> 30 31 <TableLayout 32 android:layout_width="match_parent" 33 android:layout_height="wrap_content" 34 android:gravity="center" 35 android:stretchColumns="1" 36 android:background="#FFFFFF" 37 android:padding="16dp" 38 android:elevation="2dp" 39 android:layout_marginTop="8dp" 40 android:radius="8dp"> 41 42 <TableRow 43 android:layout_width="wrap_content" 44 android:layout_height="50dp" 45 android:minHeight="50dp"> 46 47 <TextView 48 android:layout_width="wrap_content" 49 android:layout_height="wrap_content" 50 android:text="@string/id" 51 android:textSize="16sp" 52 android:textColor="#212121" 53 android:textStyle="bold" 54 android:layout_gravity="center_vertical"/> 55 56 <TextView 57 android:id="@+id/idTV" 58 android:layout_width="wrap_content" 59 android:layout_height="wrap_content" 60 android:paddingLeft="10dp" 61 android:text="@string/unDesigned" 62 android:textSize="16sp" 63 android:textColor="#616161" 64 android:layout_gravity="center_vertical"/> 65 </TableRow> 66 67 <View 68 android:layout_width="match_parent" 69 android:layout_height="1dp" 70 android:background="#EEEEEE" 71 android:layout_marginVertical="4dp"/> 72 73 <TableRow 74 android:layout_width="wrap_content" 75 android:layout_height="50dp" 76 android:minHeight="50dp"> 77 78 <TextView 79 android:layout_width="wrap_content" 80 android:layout_height="wrap_content" 81 android:text="@string/name" 82 android:textSize="16sp" 83 android:textColor="#212121" 84 android:textStyle="bold" 85 android:layout_gravity="center_vertical"/> 86 87 <LinearLayout 88 android:layout_width="wrap_content" 89 android:layout_height="wrap_content" 90 android:orientation="horizontal" 91 android:layout_gravity="center_vertical"> 92 93 <TextView 94 android:id="@+id/nameTV" 95 android:layout_width="wrap_content" 96 android:layout_height="wrap_content" 97 android:paddingLeft="10dp" 98 android:text="@string/unDesigned" 99 android:textSize="16sp" 100 android:textColor="#616161"/> 101 102 <EditText 103 android:id="@+id/nameET" 104 android:layout_width="200dp" 105 android:layout_height="40dp" 106 android:visibility="gone" 107 android:background="#F5F5F5" 108 android:paddingLeft="8dp" 109 android:textSize="16sp"/> 110 </LinearLayout> 111 </TableRow> 112 113 <View 114 android:layout_width="match_parent" 115 android:layout_height="1dp" 116 android:background="#EEEEEE" 117 android:layout_marginVertical="4dp"/> 118 119 <TableRow 120 android:layout_width="wrap_content" 121 android:layout_height="50dp" 122 android:minHeight="50dp"> 123 124 <TextView 125 android:layout_width="wrap_content" 126 android:layout_height="wrap_content" 127 android:text="@string/sex" 128 android:textSize="16sp" 129 android:textColor="#212121" 130 android:textStyle="bold" 131 android:layout_gravity="center_vertical"/> 132 133 <LinearLayout 134 android:layout_width="wrap_content" 135 android:layout_height="wrap_content" 136 android:orientation="horizontal" 137 android:layout_gravity="center_vertical"> 138 139 <TextView 140 android:id="@+id/sexTV" 141 android:layout_width="wrap_content" 142 android:layout_height="wrap_content" 143 android:paddingLeft="10dp" 144 android:text="@string/unDesigned" 145 android:textSize="16sp" 146 android:textColor="#616161"/> 147 148 <EditText 149 android:id="@+id/sexET" 150 android:layout_width="200dp" 151 android:layout_height="40dp" 152 android:visibility="gone" 153 android:background="#F5F5F5" 154 android:paddingLeft="8dp" 155 android:textSize="16sp"/> 156 </LinearLayout> 157 </TableRow> 158 159 <View 160 android:layout_width="match_parent" 161 android:layout_height="1dp" 162 android:background="#EEEEEE" 163 android:layout_marginVertical="4dp"/> 164 165 <TableRow 166 android:layout_width="wrap_content" 167 android:layout_height="50dp" 168 android:minHeight="50dp"> 169 170 <TextView 171 android:layout_width="wrap_content" 172 android:layout_height="wrap_content" 173 android:text="@string/birthday" 174 android:textSize="16sp" 175 android:textColor="#212121" 176 android:textStyle="bold" 177 android:layout_gravity="center_vertical"/> 178 179 <LinearLayout 180 android:layout_width="wrap_content" 181 android:layout_height="wrap_content" 182 android:orientation="horizontal" 183 android:layout_gravity="center_vertical"> 184 185 <TextView 186 android:id="@+id/birthdayTV" 187 android:layout_width="wrap_content" 188 android:layout_height="wrap_content" 189 android:paddingLeft="10dp" 190 android:text="@string/unDesigned" 191 android:textSize="16sp" 192 android:textColor="#616161"/> 193 194 <EditText 195 android:id="@+id/birthdayET" 196 android:layout_width="200dp" 197 android:layout_height="40dp" 198 android:inputType="date" 199 android:visibility="gone" 200 android:background="#F5F5F5" 201 android:paddingLeft="8dp" 202 android:textSize="16sp"/> 203 </LinearLayout> 204 </TableRow> 205 206 <View 207 android:layout_width="match_parent" 208 android:layout_height="1dp" 209 android:background="#EEEEEE" 210 android:layout_marginVertical="4dp"/> 211 212 <TableRow 213 android:layout_width="wrap_content" 214 android:layout_height="50dp" 215 android:minHeight="50dp"> 216 217 <TextView 218 android:layout_width="wrap_content" 219 android:layout_height="wrap_content" 220 android:text="@string/nationality" 221 android:textSize="16sp" 222 android:textColor="#212121" 223 android:textStyle="bold" 224 android:layout_gravity="center_vertical"/> 225 226 <LinearLayout 227 android:layout_width="wrap_content" 228 android:layout_height="wrap_content" 229 android:orientation="horizontal" 230 android:layout_gravity="center_vertical"> 231 232 <TextView 233 android:id="@+id/nationalityTV" 234 android:layout_width="wrap_content" 235 android:layout_height="wrap_content" 236 android:paddingLeft="10dp" 237 android:text="@string/unDesigned" 238 android:textSize="16sp" 239 android:textColor="#616161"/> 240 241 <EditText 242 android:id="@+id/nationalityET" 243 android:layout_width="200dp" 244 android:layout_height="40dp" 245 android:visibility="gone" 246 android:background="#F5F5F5" 247 android:paddingLeft="8dp" 248 android:textSize="16sp"/> 249 </LinearLayout> 250 </TableRow> 251 252 <View 253 android:layout_width="match_parent" 254 android:layout_height="1dp" 255 android:background="#EEEEEE" 256 android:layout_marginVertical="4dp"/> 257 258 <TableRow 259 android:layout_width="wrap_content" 260 android:layout_height="50dp" 261 android:minHeight="50dp"> 262 263 <TextView 264 android:layout_width="wrap_content" 265 android:layout_height="wrap_content" 266 android:text="@string/education" 267 android:textSize="16sp" 268 android:textColor="#212121" 269 android:textStyle="bold" 270 android:layout_gravity="center_vertical"/> 271 272 <LinearLayout 273 android:layout_width="wrap_content" 274 android:layout_height="wrap_content" 275 android:orientation="horizontal" 276 android:layout_gravity="center_vertical"> 277 278 <TextView 279 android:id="@+id/educationTV" 280 android:layout_width="wrap_content" 281 android:layout_height="wrap_content" 282 android:paddingLeft="10dp" 283 android:text="@string/unDesigned" 284 android:textSize="16sp" 285 android:textColor="#616161"/> 286 287 <EditText 288 android:id="@+id/educationET" 289 android:layout_width="200dp" 290 android:layout_height="40dp" 291 android:visibility="gone" 292 android:background="#F5F5F5" 293 android:paddingLeft="8dp" 294 android:textSize="16sp"/> 295 </LinearLayout> 296 </TableRow> 297 298 <View 299 android:layout_width="match_parent" 300 android:layout_height="1dp" 301 android:background="#EEEEEE" 302 android:layout_marginVertical="4dp"/> 303 304 <TableRow 305 android:layout_width="wrap_content" 306 android:layout_height="50dp" 307 android:minHeight="50dp"> 308 309 <TextView 310 android:layout_width="wrap_content" 311 android:layout_height="wrap_content" 312 android:text="@string/religion" 313 android:textSize="16sp" 314 android:textColor="#212121" 315 android:textStyle="bold" 316 android:layout_gravity="center_vertical"/> 317 318 <LinearLayout 319 android:layout_width="wrap_content" 320 android:layout_height="wrap_content" 321 android:orientation="horizontal" 322 android:layout_gravity="center_vertical"> 323 324 <TextView 325 android:id="@+id/religionTV" 326 android:layout_width="wrap_content" 327 android:layout_height="wrap_content" 328 android:paddingLeft="10dp" 329 android:text="@string/unDesigned" 330 android:textSize="16sp" 331 android:textColor="#616161"/> 332 333 <EditText 334 android:id="@+id/religionET" 335 android:layout_width="200dp" 336 android:layout_height="40dp" 337 android:visibility="gone" 338 android:background="#F5F5F5" 339 android:paddingLeft="8dp" 340 android:textSize="16sp"/> 341 </LinearLayout> 342 </TableRow> 343 344 <View 345 android:layout_width="match_parent" 346 android:layout_height="1dp" 347 android:background="#EEEEEE" 348 android:layout_marginVertical="4dp"/> 349 350 <TableRow 351 android:layout_width="wrap_content" 352 android:layout_height="50dp" 353 android:minHeight="50dp"> 354 355 <TextView 356 android:layout_width="wrap_content" 357 android:layout_height="wrap_content" 358 android:text="@string/marriage" 359 android:textSize="16sp" 360 android:textColor="#212121" 361 android:textStyle="bold" 362 android:layout_gravity="center_vertical"/> 363 364 <LinearLayout 365 android:layout_width="wrap_content" 366 android:layout_height="wrap_content" 367 android:orientation="horizontal" 368 android:layout_gravity="center_vertical"> 369 370 <TextView 371 android:id="@+id/marriageTV" 372 android:layout_width="wrap_content" 373 android:layout_height="wrap_content" 374 android:paddingLeft="10dp" 375 android:text="@string/unDesigned" 376 android:textSize="16sp" 377 android:textColor="#616161"/> 378 379 <EditText 380 android:id="@+id/marriageET" 381 android:layout_width="200dp" 382 android:layout_height="40dp" 383 android:visibility="gone" 384 android:background="#F5F5F5" 385 android:paddingLeft="8dp" 386 android:textSize="16sp"/> 387 </LinearLayout> 388 </TableRow> 389 390 <View 391 android:layout_width="match_parent" 392 android:layout_height="1dp" 393 android:background="#EEEEEE" 394 android:layout_marginVertical="4dp"/> 395 396 <TableRow 397 android:layout_width="wrap_content" 398 android:layout_height="50dp" 399 android:minHeight="50dp"> 400 401 <TextView 402 android:layout_width="wrap_content" 403 android:layout_height="wrap_content" 404 android:text="@string/residence" 405 android:textSize="16sp" 406 android:textColor="#212121" 407 android:textStyle="bold" 408 android:layout_gravity="center_vertical"/> 409 410 <LinearLayout 411 android:layout_width="wrap_content" 412 android:layout_height="wrap_content" 413 android:orientation="horizontal" 414 android:layout_gravity="center_vertical"> 415 416 <TextView 417 android:id="@+id/residenceTV" 418 android:layout_width="wrap_content" 419 android:layout_height="wrap_content" 420 android:paddingLeft="10dp" 421 android:text="@string/unDesigned" 422 android:textSize="16sp" 423 android:textColor="#616161"/> 424 425 <EditText 426 android:id="@+id/residenceET" 427 android:layout_width="200dp" 428 android:layout_height="40dp" 429 android:visibility="gone" 430 android:background="#F5F5F5" 431 android:paddingLeft="8dp" 432 android:textSize="16sp"/> 433 </LinearLayout> 434 </TableRow> 435 436 <View 437 android:layout_width="match_parent" 438 android:layout_height="1dp" 439 android:background="#EEEEEE" 440 android:layout_marginVertical="4dp"/> 441 442 <TableRow 443 android:layout_width="wrap_content" 444 android:layout_height="50dp" 445 android:minHeight="50dp"> 446 447 <TextView 448 android:layout_width="wrap_content" 449 android:layout_height="wrap_content" 450 android:text="@string/financial" 451 android:textSize="16sp" 452 android:textColor="#212121" 453 android:textStyle="bold" 454 android:layout_gravity="center_vertical"/> 455 456 <LinearLayout 457 android:layout_width="wrap_content" 458 android:layout_height="wrap_content" 459 android:orientation="horizontal" 460 android:layout_gravity="center_vertical"> 461 462 <TextView 463 android:id="@+id/financialTV" 464 android:layout_width="wrap_content" 465 android:layout_height="wrap_content" 466 android:paddingLeft="10dp" 467 android:text="@string/unDesigned" 468 android:textSize="16sp" 469 android:textColor="#616161"/> 470 471 <EditText 472 android:id="@+id/financialET" 473 android:layout_width="200dp" 474 android:layout_height="40dp" 475 android:visibility="gone" 476 android:background="#F5F5F5" 477 android:paddingLeft="8dp" 478 android:textSize="16sp"/> 479 </LinearLayout> 480 </TableRow> 481 482 <View 483 android:layout_width="match_parent" 484 android:layout_height="1dp" 485 android:background="#EEEEEE" 486 android:layout_marginVertical="4dp"/> 487 488 <TableRow 489 android:layout_width="wrap_content" 490 android:layout_height="50dp" 491 android:minHeight="50dp"> 492 493 <TextView 494 android:layout_width="wrap_content" 495 android:layout_height="wrap_content" 496 android:text="@string/disease" 497 android:textSize="16sp" 498 android:textColor="#212121" 499 android:textStyle="bold" 500 android:layout_gravity="center_vertical"/> 501 502 <LinearLayout 503 android:layout_width="wrap_content" 504 android:layout_height="wrap_content" 505 android:orientation="horizontal" 506 android:layout_gravity="center_vertical"> 507 508 <TextView 509 android:id="@+id/diseaseTV" 510 android:layout_width="wrap_content" 511 android:layout_height="wrap_content" 512 android:paddingLeft="10dp" 513 android:text="@string/unDesigned" 514 android:textSize="16sp" 515 android:textColor="#616161"/> 516 517 <EditText 518 android:id="@+id/diseaseET" 519 android:layout_width="200dp" 520 android:layout_height="40dp" 521 android:visibility="gone" 522 android:background="#F5F5F5" 523 android:paddingLeft="8dp" 524 android:textSize="16sp"/> 525 </LinearLayout> 526 </TableRow> 527 528 <TableRow 529 android:layout_width="wrap_content" 530 android:layout_height="wrap_content" 531 android:paddingTop="20dp" 532 android:gravity="center"> 533 534 <Button 535 android:id="@+id/updateBtn" 536 android:layout_width="80dp" 537 android:layout_height="40dp" 538 android:text="@string/update" 539 android:backgroundTint="#03A9D4" 540 android:onClick="update" 541 android:textColor="#FFFFFF" 542 android:layout_marginHorizontal="8dp" 543 android:elevation="1dp"/> 544 545 <Button 546 android:id="@+id/backBtn" 547 android:layout_width="80dp" 548 android:layout_height="40dp" 549 android:text="@string/back" 550 android:backgroundTint="#03A9D4" 551 android:onClick="back" 552 android:textColor="#FFFFFF" 553 android:layout_marginHorizontal="8dp" 554 android:elevation="1dp"/> 555 556 <Button 557 android:id="@+id/confirmBtn" 558 android:layout_width="80dp" 559 android:layout_height="40dp" 560 android:text="@string/confirm" 561 android:backgroundTint="#03A9D4" 562 android:visibility="gone" 563 android:onClick="confirm" 564 android:textColor="#FFFFFF" 565 android:layout_marginHorizontal="8dp" 566 android:elevation="1dp"/> 567 568 <Button 569 android:id="@+id/cancelBtn" 570 android:layout_width="80dp" 571 android:layout_height="40dp" 572 android:text="@string/cancel" 573 android:backgroundTint="#03A9D4" 574 android:visibility="gone" 575 android:onClick="cancel" 576 android:textColor="#FFFFFF" 577 android:layout_marginHorizontal="8dp" 578 android:elevation="1dp"/> 579 </TableRow> 580 581 </TableLayout> 582 </ScrollView> 583 584 </LinearLayout>
UserInfoActivity.class
1 package com.app; 2 3 import android.content.Intent; 4 import android.content.SharedPreferences; 5 import android.os.Bundle; 6 import android.view.View; 7 import android.widget.Button; 8 import android.widget.EditText; 9 import android.widget.TextView; 10 import androidx.appcompat.app.AppCompatActivity; 11 12 import com.app.Entity.User; 13 import com.app.api.UserService; 14 15 import retrofit2.Call; 16 import retrofit2.Callback; 17 import retrofit2.Response; 18 import retrofit2.Retrofit; 19 import retrofit2.converter.gson.GsonConverterFactory; 20 21 public class UserInfoActivity extends AppCompatActivity { 22 23 Retrofit retrofit; 24 UserService userService; 25 26 private String id; 27 private TextView[] tvArray; 28 private EditText[] etArray; 29 private User user; 30 private TextView idTV; 31 private Button updateBtn, backBtn, confirmBtn, cancelBtn; 32 33 @Override 34 protected void onCreate(Bundle savedInstanceState) { 35 super.onCreate(savedInstanceState); 36 setContentView(R.layout.activity_user_info); 37 38 initViews(); 39 40 retrofit =new Retrofit.Builder().baseUrl("http://192.168.0.2:8080") 41 .addConverterFactory(GsonConverterFactory.create()) 42 .build(); 43 userService = retrofit.create(UserService.class); 44 45 initData(); 46 } 47 48 private void initViews() { 49 idTV = findViewById(R.id.idTV); 50 51 tvArray = new TextView[]{ 52 findViewById(R.id.nameTV), 53 findViewById(R.id.sexTV), 54 findViewById(R.id.birthdayTV), 55 findViewById(R.id.nationalityTV), 56 findViewById(R.id.educationTV), 57 findViewById(R.id.religionTV), 58 findViewById(R.id.marriageTV), 59 findViewById(R.id.residenceTV), 60 findViewById(R.id.financialTV), 61 findViewById(R.id.diseaseTV) 62 }; 63 64 etArray = new EditText[]{ 65 findViewById(R.id.nameET), 66 findViewById(R.id.sexET), 67 findViewById(R.id.birthdayET), 68 findViewById(R.id.nationalityET), 69 findViewById(R.id.educationET), 70 findViewById(R.id.religionET), 71 findViewById(R.id.marriageET), 72 findViewById(R.id.residenceET), 73 findViewById(R.id.financialET), 74 findViewById(R.id.diseaseET) 75 }; 76 77 updateBtn = findViewById(R.id.updateBtn); 78 backBtn = findViewById(R.id.backBtn); 79 confirmBtn = findViewById(R.id.confirmBtn); 80 cancelBtn = findViewById(R.id.cancelBtn); 81 } 82 83 private void initData(){ 84 SharedPreferences sp = getSharedPreferences("userInfo",MODE_PRIVATE); 85 id = sp.getString("id",""); 86 87 Call<User> call = userService.getInfo(id); 88 call.enqueue(new Callback<User>() { 89 @Override 90 public void onResponse(Call<User> call, Response<User> response) { 91 user = response.body(); 92 idTV.setText(user.getId()); 93 tvArray[0].setText(user.getName() != null && !user.getName().isEmpty() ? user.getName() : "未设置"); 94 tvArray[1].setText(user.getSex() != null && !user.getSex().isEmpty() ? user.getSex() : "未设置"); 95 tvArray[2].setText(user.getBirthday() != null && !user.getBirthday().isEmpty() ? user.getBirthday() : "未设置"); 96 tvArray[3].setText(user.getNationality() != null && !user.getNationality().isEmpty() ? user.getNationality() : "未设置"); 97 tvArray[4].setText(user.getEducation() != null && !user.getEducation().isEmpty() ? user.getEducation() : "未设置"); 98 tvArray[5].setText(user.getReligion() != null && !user.getReligion().isEmpty() ? user.getReligion() : "未设置"); 99 tvArray[6].setText(user.getMarriage() != null && !user.getMarriage().isEmpty() ? user.getMarriage() : "未设置"); 100 tvArray[7].setText(user.getResidence() != null && !user.getResidence().isEmpty() ? user.getResidence() : "未设置"); 101 tvArray[8].setText(user.getFinancial() != null && !user.getFinancial().isEmpty() ? user.getFinancial() : "未设置"); 102 tvArray[9].setText(user.getDisease() != null && !user.getDisease().isEmpty() ? user.getDisease() : "未设置"); 103 104 for (int i = 0; i < tvArray.length; i++) { 105 etArray[i].setText(tvArray[i].getText()); 106 } 107 } 108 109 @Override 110 public void onFailure(Call<User> call, Throwable t) { 111 112 } 113 }); 114 } 115 116 public void update(View view) { 117 for (int i = 0; i < tvArray.length; i++) { 118 tvArray[i].setVisibility(View.GONE); 119 etArray[i].setVisibility(View.VISIBLE); 120 } 121 updateBtn.setVisibility(View.GONE); 122 backBtn.setVisibility(View.GONE); 123 confirmBtn.setVisibility(View.VISIBLE); 124 cancelBtn.setVisibility(View.VISIBLE); 125 } 126 127 public void back(View view) { 128 startActivity(new Intent(UserInfoActivity.this, HomeActivity.class)); 129 } 130 131 public void confirm(View view) { 132 133 user.setName(etArray[0].getText().toString()); 134 user.setSex(etArray[1].getText().toString()); 135 user.setBirthday(etArray[2].getText().toString()); 136 user.setNationality(etArray[3].getText().toString()); 137 user.setEducation(etArray[4].getText().toString()); 138 user.setReligion(etArray[5].getText().toString()); 139 user.setMarriage(etArray[6].getText().toString()); 140 user.setResidence(etArray[7].getText().toString()); 141 user.setFinancial(etArray[8].getText().toString()); 142 user.setDisease(etArray[9].getText().toString()); 143 144 Call<User> call = userService.update(user); 145 call.enqueue(new Callback<User>() { 146 @Override 147 public void onResponse(Call<User> call, Response<User> response) { 148 149 } 150 @Override 151 public void onFailure(Call<User> call, Throwable t) { 152 153 } 154 }); 155 156 for(int i=0;i<tvArray.length;i++){ 157 tvArray[i].setText(etArray[i].getText()); 158 } 159 for (int i = 0; i < tvArray.length; i++) { 160 tvArray[i].setVisibility(View.VISIBLE); 161 etArray[i].setVisibility(View.GONE); 162 } 163 updateBtn.setVisibility(View.VISIBLE); 164 backBtn.setVisibility(View.VISIBLE); 165 confirmBtn.setVisibility(View.GONE); 166 cancelBtn.setVisibility(View.GONE); 167 168 } 169 170 public void cancel(View view) { 171 for (int i = 0; i < tvArray.length; i++) { 172 tvArray[i].setVisibility(View.VISIBLE); 173 etArray[i].setVisibility(View.GONE); 174 } 175 updateBtn.setVisibility(View.VISIBLE); 176 backBtn.setVisibility(View.VISIBLE); 177 confirmBtn.setVisibility(View.GONE); 178 cancelBtn.setVisibility(View.GONE); 179 } 180 }
activity_test.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical"> 7 8 <TextView 9 android:layout_width="match_parent" 10 android:layout_height="60dp" 11 android:background="#03A9F4" 12 android:gravity="center" 13 android:text="@string/SystemTitle" 14 android:textColor="#FFFFFF" 15 android:textSize="30sp"/> 16 17 <TextView 18 android:id="@+id/title" 19 android:layout_width="match_parent" 20 android:layout_height="30dp" 21 android:text="@string/DL" 22 android:background="#03A9D4" 23 android:gravity="center_vertical" 24 android:paddingLeft="10dp"/> 25 26 <ScrollView 27 android:layout_width="match_parent" 28 android:layout_height="0dp" 29 android:layout_weight="1" 30 android:padding="16dp"> 31 32 <LinearLayout 33 android:layout_width="match_parent" 34 android:layout_height="wrap_content" 35 android:orientation="vertical"> 36 37 <LinearLayout 38 android:id="@+id/DL" 39 android:layout_width="match_parent" 40 android:layout_height="wrap_content" 41 android:orientation="vertical" 42 android:visibility="visible"> 43 44 <TextView 45 android:layout_width="match_parent" 46 android:layout_height="wrap_content" 47 android:layout_marginBottom="8dp" 48 android:text="1.1 进食:指用餐具将食物由容器送到口中、咀嚼、吞咽等过程" 49 android:textSize="16sp"/> 50 <RadioGroup 51 android:id="@+id/q1.1" 52 android:layout_width="match_parent" 53 android:layout_height="wrap_content" 54 android:layout_marginLeft="16dp" 55 android:layout_marginBottom="16dp" 56 android:orientation="vertical"> 57 <RadioButton 58 android:layout_width="match_parent" 59 android:layout_height="wrap_content" 60 android:layout_marginBottom="4dp" 61 android:text="可独立进食(在合理的时间内独立进食准备好的食物)" 62 android:tag="10" 63 android:textSize="14sp"/> 64 <RadioButton 65 android:layout_width="match_parent" 66 android:layout_height="wrap_content" 67 android:layout_marginBottom="4dp" 68 android:text="需部分帮助(进食过程中需要一定帮助,如协助把持餐具)" 69 android:tag="5" 70 android:textSize="14sp"/> 71 <RadioButton 72 android:layout_width="match_parent" 73 android:layout_height="wrap_content" 74 android:text="需极大帮助或完全依赖他人,或有留置营养管" 75 android:tag="0" 76 android:textSize="14sp"/> 77 </RadioGroup> 78 79 <View 80 android:layout_width="match_parent" 81 android:layout_height="1dp" 82 android:layout_marginVertical="8dp" 83 android:background="#E0E0E0"/> 84 85 <TextView 86 android:layout_width="match_parent" 87 android:layout_height="wrap_content" 88 android:layout_marginBottom="8dp" 89 android:text="1.2 洗澡" 90 android:textSize="16sp"/> 91 <RadioGroup 92 android:id="@+id/q1.2" 93 android:layout_width="match_parent" 94 android:layout_height="wrap_content" 95 android:layout_marginLeft="16dp" 96 android:layout_marginBottom="16dp" 97 android:orientation="vertical"> 98 <RadioButton 99 android:layout_width="match_parent" 100 android:layout_height="wrap_content" 101 android:layout_marginBottom="4dp" 102 android:text="准备好洗澡水后,可自己独立完成洗澡过程" 103 android:tag="5" 104 android:textSize="14sp"/> 105 <RadioButton 106 android:layout_width="match_parent" 107 android:layout_height="wrap_content" 108 android:text="在洗澡过程中需他人帮助" 109 android:tag="0" 110 android:textSize="14sp"/> 111 </RadioGroup> 112 113 <View 114 android:layout_width="match_parent" 115 android:layout_height="1dp" 116 android:layout_marginVertical="8dp" 117 android:background="#E0E0E0"/> 118 119 <TextView 120 android:layout_width="match_parent" 121 android:layout_height="wrap_content" 122 android:layout_marginBottom="8dp" 123 android:text="1.3 修饰:指洗脸、刷牙、梳头、刮脸等" 124 android:textSize="16sp"/> 125 <RadioGroup 126 android:id="@+id/q1.3" 127 android:layout_width="match_parent" 128 android:layout_height="wrap_content" 129 android:layout_marginLeft="16dp" 130 android:layout_marginBottom="16dp" 131 android:orientation="vertical"> 132 <RadioButton 133 android:layout_width="match_parent" 134 android:layout_height="wrap_content" 135 android:layout_marginBottom="4dp" 136 android:text="可自己独立完成" 137 android:tag="5" 138 android:textSize="14sp"/> 139 <RadioButton 140 android:layout_width="match_parent" 141 android:layout_height="wrap_content" 142 android:text="需他人帮助" 143 android:tag="0" 144 android:textSize="14sp"/> 145 </RadioGroup> 146 147 <View 148 android:layout_width="match_parent" 149 android:layout_height="1dp" 150 android:layout_marginVertical="8dp" 151 android:background="#E0E0E0"/> 152 153 <TextView 154 android:layout_width="match_parent" 155 android:layout_height="wrap_content" 156 android:layout_marginBottom="8dp" 157 android:text="1.4 穿衣:指穿脱衣服、系扣、拉拉链、穿脱鞋袜、系鞋带" 158 android:textSize="16sp"/> 159 <RadioGroup 160 android:id="@+id/q1.4" 161 android:layout_width="match_parent" 162 android:layout_height="wrap_content" 163 android:layout_marginLeft="16dp" 164 android:layout_marginBottom="16dp" 165 android:orientation="vertical"> 166 <RadioButton 167 android:layout_width="match_parent" 168 android:layout_height="wrap_content" 169 android:layout_marginBottom="4dp" 170 android:text="可独立完成" 171 android:tag="10" 172 android:textSize="14sp"/> 173 <RadioButton 174 android:layout_width="match_parent" 175 android:layout_height="wrap_content" 176 android:layout_marginBottom="4dp" 177 android:text="需部分帮助(能自己穿脱,但需他人帮助整理衣物、系扣/鞋带、拉拉链)" 178 android:tag="5" 179 android:textSize="14sp"/> 180 <RadioButton 181 android:layout_width="match_parent" 182 android:layout_height="wrap_content" 183 android:text="需极大帮助或完全依赖他人" 184 android:tag="0" 185 android:textSize="14sp"/> 186 </RadioGroup> 187 188 <View 189 android:layout_width="match_parent" 190 android:layout_height="1dp" 191 android:layout_marginVertical="8dp" 192 android:background="#E0E0E0"/> 193 194 <TextView 195 android:layout_width="match_parent" 196 android:layout_height="wrap_content" 197 android:layout_marginBottom="8dp" 198 android:text="1.5 大便控制" 199 android:textSize="16sp"/> 200 <RadioGroup 201 android:id="@+id/q1.5" 202 android:layout_width="match_parent" 203 android:layout_height="wrap_content" 204 android:layout_marginLeft="16dp" 205 android:layout_marginBottom="16dp" 206 android:orientation="vertical"> 207 <RadioButton 208 android:layout_width="match_parent" 209 android:layout_height="wrap_content" 210 android:layout_marginBottom="4dp" 211 android:text="可控制大便" 212 android:tag="10" 213 android:textSize="14sp"/> 214 <RadioButton 215 android:layout_width="match_parent" 216 android:layout_height="wrap_content" 217 android:layout_marginBottom="4dp" 218 android:text="偶尔失控(每周 < 1次),或需要他人提示" 219 android:tag="5" 220 android:textSize="14sp"/> 221 <RadioButton 222 android:layout_width="match_parent" 223 android:layout_height="wrap_content" 224 android:text="完全失控" 225 android:tag="0" 226 android:textSize="14sp"/> 227 </RadioGroup> 228 229 <View 230 android:layout_width="match_parent" 231 android:layout_height="1dp" 232 android:layout_marginVertical="8dp" 233 android:background="#E0E0E0"/> 234 235 <TextView 236 android:layout_width="match_parent" 237 android:layout_height="wrap_content" 238 android:layout_marginBottom="8dp" 239 android:text="1.6 小便控制" 240 android:textSize="16sp"/> 241 <RadioGroup 242 android:id="@+id/q1.6" 243 android:layout_width="match_parent" 244 android:layout_height="wrap_content" 245 android:layout_marginLeft="16dp" 246 android:layout_marginBottom="16dp" 247 android:orientation="vertical"> 248 <RadioButton 249 android:layout_width="match_parent" 250 android:layout_height="wrap_content" 251 android:layout_marginBottom="4dp" 252 android:text="可控制小便" 253 android:tag="10" 254 android:textSize="14sp"/> 255 <RadioButton 256 android:layout_width="match_parent" 257 android:layout_height="wrap_content" 258 android:layout_marginBottom="4dp" 259 android:text="偶尔失控(每天<1次,但每周>1次),或需要他人提示" 260 android:tag="5" 261 android:textSize="14sp"/> 262 <RadioButton 263 android:layout_width="match_parent" 264 android:layout_height="wrap_content" 265 android:text="完全失控,或留置导尿管" 266 android:tag="0" 267 android:textSize="14sp"/> 268 </RadioGroup> 269 270 <View 271 android:layout_width="match_parent" 272 android:layout_height="1dp" 273 android:layout_marginVertical="8dp" 274 android:background="#E0E0E0"/> 275 276 <TextView 277 android:layout_width="match_parent" 278 android:layout_height="wrap_content" 279 android:layout_marginBottom="8dp" 280 android:text="1.7 如厕:包括去厕所、解开衣裤、擦净、整理衣裤、冲水" 281 android:textSize="16sp"/> 282 <RadioGroup 283 android:id="@+id/q1.7" 284 android:layout_width="match_parent" 285 android:layout_height="wrap_content" 286 android:layout_marginLeft="16dp" 287 android:layout_marginBottom="16dp" 288 android:orientation="vertical"> 289 <RadioButton 290 android:layout_width="match_parent" 291 android:layout_height="wrap_content" 292 android:layout_marginBottom="4dp" 293 android:text="可独立完成" 294 android:tag="10" 295 android:textSize="14sp"/> 296 <RadioButton 297 android:layout_width="match_parent" 298 android:layout_height="wrap_content" 299 android:layout_marginBottom="4dp" 300 android:text="需部分帮助(需他人搀扶去厕所、需他人帮忙冲水或整理衣裤等)" 301 android:tag="5" 302 android:textSize="14sp"/> 303 <RadioButton 304 android:layout_width="match_parent" 305 android:layout_height="wrap_content" 306 android:text="需极大帮助或完全依赖他人" 307 android:tag="0" 308 android:textSize="14sp"/> 309 </RadioGroup> 310 311 <View 312 android:layout_width="match_parent" 313 android:layout_height="1dp" 314 android:layout_marginVertical="8dp" 315 android:background="#E0E0E0"/> 316 317 <TextView 318 android:layout_width="match_parent" 319 android:layout_height="wrap_content" 320 android:layout_marginBottom="8dp" 321 android:text="1.8 床椅转移" 322 android:textSize="16sp"/> 323 <RadioGroup 324 android:id="@+id/q1.8" 325 android:layout_width="match_parent" 326 android:layout_height="wrap_content" 327 android:layout_marginLeft="16dp" 328 android:layout_marginBottom="16dp" 329 android:orientation="vertical"> 330 <RadioButton 331 android:layout_width="match_parent" 332 android:layout_height="wrap_content" 333 android:layout_marginBottom="4dp" 334 android:text="可独立完成" 335 android:tag="15" 336 android:textSize="14sp"/> 337 <RadioButton 338 android:layout_width="match_parent" 339 android:layout_height="wrap_content" 340 android:layout_marginBottom="4dp" 341 android:text="需部分帮助(需他人搀扶或使用拐杖)" 342 android:tag="10" 343 android:textSize="14sp"/> 344 <RadioButton 345 android:layout_width="match_parent" 346 android:layout_height="wrap_content" 347 android:layout_marginBottom="4dp" 348 android:text="需极大帮助(较大程度上依赖他人搀扶和帮助)" 349 android:tag="5" 350 android:textSize="14sp"/> 351 <RadioButton 352 android:layout_width="match_parent" 353 android:layout_height="wrap_content" 354 android:text="完全依赖他人" 355 android:tag="0" 356 android:textSize="14sp"/> 357 </RadioGroup> 358 359 <View 360 android:layout_width="match_parent" 361 android:layout_height="1dp" 362 android:layout_marginVertical="8dp" 363 android:background="#E0E0E0"/> 364 365 <TextView 366 android:layout_width="match_parent" 367 android:layout_height="wrap_content" 368 android:layout_marginBottom="8dp" 369 android:text="1.9 平地行走" 370 android:textSize="16sp"/> 371 <RadioGroup 372 android:id="@+id/q1.9" 373 android:layout_width="match_parent" 374 android:layout_height="wrap_content" 375 android:layout_marginLeft="16dp" 376 android:layout_marginBottom="16dp" 377 android:orientation="vertical"> 378 <RadioButton 379 android:layout_width="match_parent" 380 android:layout_height="wrap_content" 381 android:layout_marginBottom="4dp" 382 android:text="可独立在平地上行走45m" 383 android:tag="15" 384 android:textSize="14sp"/> 385 <RadioButton 386 android:layout_width="match_parent" 387 android:layout_height="wrap_content" 388 android:layout_marginBottom="4dp" 389 android:text="需部分帮助(因肢体残疾、平衡能力差、过度衰弱、视力等问题,在一定程度上需他人地搀扶或使用拐杖、助行器等辅助用具)" 390 android:tag="10" 391 android:textSize="14sp"/> 392 <RadioButton 393 android:layout_width="match_parent" 394 android:layout_height="wrap_content" 395 android:layout_marginBottom="4dp" 396 android:text="需极大帮助(因肢体残疾、平衡能力差、过度衰弱、视力等问题,在较大程度上依赖他人搀扶,或坐在轮椅上自行移动)" 397 android:tag="5" 398 android:textSize="14sp"/> 399 <RadioButton 400 android:layout_width="match_parent" 401 android:layout_height="wrap_content" 402 android:text="完全依赖他人" 403 android:tag="0" 404 android:textSize="14sp"/> 405 </RadioGroup> 406 407 <View 408 android:layout_width="match_parent" 409 android:layout_height="1dp" 410 android:layout_marginVertical="8dp" 411 android:background="#E0E0E0"/> 412 413 <TextView 414 android:layout_width="match_parent" 415 android:layout_height="wrap_content" 416 android:layout_marginBottom="8dp" 417 android:text="1.10 上下楼梯" 418 android:textSize="16sp"/> 419 <RadioGroup 420 android:id="@+id/q1.10" 421 android:layout_width="match_parent" 422 android:layout_height="wrap_content" 423 android:layout_marginLeft="16dp" 424 android:layout_marginBottom="16dp" 425 android:orientation="vertical"> 426 <RadioButton 427 android:layout_width="match_parent" 428 android:layout_height="wrap_content" 429 android:layout_marginBottom="4dp" 430 android:text="可独立上下楼梯(连续上下10-15个台阶)" 431 android:tag="10" 432 android:textSize="14sp"/> 433 <RadioButton 434 android:layout_width="match_parent" 435 android:layout_height="wrap_content" 436 android:layout_marginBottom="4dp" 437 android:text="需部分帮助(需他人搀扶,或扶着楼梯、使用拐杖等)" 438 android:tag="5" 439 android:textSize="14sp"/> 440 <RadioButton 441 android:layout_width="match_parent" 442 android:layout_height="wrap_content" 443 android:text="需极大帮助或完全依赖他人" 444 android:tag="0" 445 android:textSize="14sp"/> 446 </RadioGroup> 447 448 <TextView 449 android:layout_width="match_parent" 450 android:layout_height="wrap_content" 451 android:layout_marginVertical="16dp" 452 android:textColor="@color/red" 453 android:text="“下面这三样东西,请记住,下一页开头会再次提到”:苹果、手表、国旗" 454 android:textSize="16sp"/> 455 456 <Button 457 android:id="@+id/DLbtn" 458 android:onClick="DLbtn" 459 android:layout_width="match_parent" 460 android:layout_height="48dp" 461 android:backgroundTint="#03A9F4" 462 android:text="提交" 463 android:textColor="#FFFFFF"/> 464 </LinearLayout> 465 466 <LinearLayout 467 android:id="@+id/MS" 468 android:layout_width="match_parent" 469 android:layout_height="wrap_content" 470 android:orientation="vertical" 471 android:visibility="gone"> 472 473 <TextView 474 android:layout_width="match_parent" 475 android:layout_height="wrap_content" 476 android:layout_marginBottom="8dp" 477 android:text="2.1 认知功能" 478 android:textSize="16sp"/> 479 <TextView 480 android:layout_width="match_parent" 481 android:layout_height="wrap_content" 482 android:layout_marginLeft="16dp" 483 android:layout_marginBottom="8dp" 484 android:text="回忆词语:“现在请您告诉我,刚才我要您记住的三样东西是什么?”(不必按顺序)" 485 android:textSize="14sp"/> 486 <EditText 487 android:id="@+id/et2.1_1" 488 android:layout_width="match_parent" 489 android:layout_height="48dp" 490 android:layout_marginLeft="16dp" 491 android:layout_marginBottom="8dp" 492 android:hint="请输入第一个词语" 493 android:paddingLeft="8dp"/> 494 <EditText 495 android:id="@+id/et2.1_2" 496 android:layout_width="match_parent" 497 android:layout_height="48dp" 498 android:layout_marginLeft="16dp" 499 android:layout_marginBottom="8dp" 500 android:hint="请输入第二个词语" 501 android:paddingLeft="8dp"/> 502 <EditText 503 android:id="@+id/et2.1_3" 504 android:layout_width="match_parent" 505 android:layout_height="48dp" 506 android:layout_marginLeft="16dp" 507 android:layout_marginBottom="16dp" 508 android:hint="请输入第三个词语" 509 android:paddingLeft="8dp"/> 510 511 <View 512 android:layout_width="match_parent" 513 android:layout_height="1dp" 514 android:layout_marginVertical="8dp" 515 android:background="#E0E0E0"/> 516 517 <TextView 518 android:layout_width="match_parent" 519 android:layout_height="wrap_content" 520 android:layout_marginBottom="8dp" 521 android:text="2.2 攻击行为" 522 android:textSize="16sp"/> 523 <RadioGroup 524 android:id="@+id/q2.2" 525 android:layout_width="match_parent" 526 android:layout_height="wrap_content" 527 android:layout_marginLeft="16dp" 528 android:layout_marginBottom="16dp" 529 android:orientation="vertical"> 530 <RadioButton 531 android:layout_width="match_parent" 532 android:layout_height="wrap_content" 533 android:layout_marginBottom="4dp" 534 android:text="无身体攻击行为(如打/踢/推/咬/抓/摔东西)和语言攻击行为(如骂人、语言威胁、尖叫)" 535 android:tag="0" 536 android:textSize="14sp"/> 537 <RadioButton 538 android:layout_width="match_parent" 539 android:layout_height="wrap_content" 540 android:layout_marginBottom="4dp" 541 android:text="每月有几次身体攻击行为,或每周有几次语言攻击行为" 542 android:tag="1" 543 android:textSize="14sp"/> 544 <RadioButton 545 android:layout_width="match_parent" 546 android:layout_height="wrap_content" 547 android:text="每周有几次身体攻击行为,或每日有语言攻击行为" 548 android:tag="2" 549 android:textSize="14sp"/> 550 </RadioGroup> 551 552 <View 553 android:layout_width="match_parent" 554 android:layout_height="1dp" 555 android:layout_marginVertical="8dp" 556 android:background="#E0E0E0"/> 557 558 <TextView 559 android:layout_width="match_parent" 560 android:layout_height="wrap_content" 561 android:layout_marginBottom="8dp" 562 android:text="2.3 抑郁症状" 563 android:textSize="16sp"/> 564 <RadioGroup 565 android:id="@+id/q2.3" 566 android:layout_width="match_parent" 567 android:layout_height="wrap_content" 568 android:layout_marginLeft="16dp" 569 android:layout_marginBottom="16dp" 570 android:orientation="vertical"> 571 <RadioButton 572 android:layout_width="match_parent" 573 android:layout_height="wrap_content" 574 android:layout_marginBottom="4dp" 575 android:text="无" 576 android:tag="0" 577 android:textSize="14sp"/> 578 <RadioButton 579 android:layout_width="match_parent" 580 android:layout_height="wrap_content" 581 android:layout_marginBottom="4dp" 582 android:text="情绪低落、不爱说话、不爱梳洗、不爱活动" 583 android:tag="1" 584 android:textSize="14sp"/> 585 <RadioButton 586 android:layout_width="match_parent" 587 android:layout_height="wrap_content" 588 android:text="有自杀念头或自杀行为" 589 android:tag="2" 590 android:textSize="14sp"/> 591 </RadioGroup> 592 593 <Button 594 android:id="@+id/MSbtn" 595 android:onClick="MSbtn" 596 android:layout_width="match_parent" 597 android:layout_height="48dp" 598 android:backgroundTint="#03A9F4" 599 android:text="提交" 600 android:textColor="#FFFFFF"/> 601 </LinearLayout> 602 603 <LinearLayout 604 android:id="@+id/SC" 605 android:layout_width="match_parent" 606 android:layout_height="wrap_content" 607 android:orientation="vertical" 608 android:visibility="gone"> 609 610 <TextView 611 android:layout_width="match_parent" 612 android:layout_height="wrap_content" 613 android:layout_marginBottom="8dp" 614 android:text="3.1 意识水平" 615 android:textSize="16sp"/> 616 <RadioGroup 617 android:id="@+id/q3.1" 618 android:layout_width="match_parent" 619 android:layout_height="wrap_content" 620 android:layout_marginLeft="16dp" 621 android:layout_marginBottom="16dp" 622 android:orientation="vertical"> 623 <RadioButton 624 android:layout_width="match_parent" 625 android:layout_height="wrap_content" 626 android:layout_marginBottom="4dp" 627 android:text="神志清醒,对周围环境警觉" 628 android:tag="0" 629 android:textSize="14sp"/> 630 <RadioButton 631 android:layout_width="match_parent" 632 android:layout_height="wrap_content" 633 android:layout_marginBottom="4dp" 634 android:text="嗜睡,表现为睡眠状态过度延长。当呼唤或推动其肢体时可唤醒,并能进行正确的交谈或执行指令,停止刺激后又继续入睡" 635 android:tag="1" 636 android:textSize="14sp"/> 637 <RadioButton 638 android:layout_width="match_parent" 639 android:layout_height="wrap_content" 640 android:layout_marginBottom="4dp" 641 android:text="昏睡,一般的外界刺激不能使其觉醒,给予较强烈的刺激时可有短时的意识清醒,醒后可简短回答提问,当刺激减弱后又很快进入睡眠状态" 642 android:tag="2" 643 android:textSize="14sp"/> 644 <RadioButton 645 android:layout_width="match_parent" 646 android:layout_height="wrap_content" 647 android:text="昏迷,处于浅昏迷时对疼痛刺激有回避和痛苦表情;处于深昏迷时对刺激无反应(若评定为昏迷,直接评定为重度失能,可不进行以下项目的评估)" 648 android:tag="3" 649 android:textSize="14sp"/> 650 </RadioGroup> 651 652 <View 653 android:layout_width="match_parent" 654 android:layout_height="1dp" 655 android:layout_marginVertical="8dp" 656 android:background="#E0E0E0"/> 657 658 <TextView 659 android:layout_width="match_parent" 660 android:layout_height="wrap_content" 661 android:layout_marginBottom="8dp" 662 android:text="3.2 视力:若平日带老花镜或近视镜,应在佩戴眼镜的情况下评估" 663 android:textSize="16sp"/> 664 <RadioGroup 665 android:id="@+id/q3.2" 666 android:layout_width="match_parent" 667 android:layout_height="wrap_content" 668 android:layout_marginLeft="16dp" 669 android:layout_marginBottom="16dp" 670 android:orientation="vertical"> 671 <RadioButton 672 android:layout_width="match_parent" 673 android:layout_height="wrap_content" 674 android:layout_marginBottom="4dp" 675 android:text="能看清书报上的标准字体" 676 android:tag="0" 677 android:textSize="14sp"/> 678 <RadioButton 679 android:layout_width="match_parent" 680 android:layout_height="wrap_content" 681 android:layout_marginBottom="4dp" 682 android:text="能看清楚大字体,但看不清书报上的标准字体" 683 android:tag="1" 684 android:textSize="14sp"/> 685 <RadioButton 686 android:layout_width="match_parent" 687 android:layout_height="wrap_content" 688 android:layout_marginBottom="4dp" 689 android:text="视力有限,看不清报纸大标题,但能辨认物体" 690 android:tag="2" 691 android:textSize="14sp"/> 692 <RadioButton 693 android:layout_width="match_parent" 694 android:layout_height="wrap_content" 695 android:layout_marginBottom="4dp" 696 android:text="辨认物体有困难,但眼睛能跟随物体移动,只能看到光、颜色和形状" 697 android:tag="3" 698 android:textSize="14sp"/> 699 <RadioButton 700 android:layout_width="match_parent" 701 android:layout_height="wrap_content" 702 android:text="没有视力,眼睛不能跟随物体移动" 703 android:tag="4" 704 android:textSize="14sp"/> 705 </RadioGroup> 706 707 <View 708 android:layout_width="match_parent" 709 android:layout_height="1dp" 710 android:layout_marginVertical="8dp" 711 android:background="#E0E0E0"/> 712 713 <TextView 714 android:layout_width="match_parent" 715 android:layout_height="wrap_content" 716 android:layout_marginBottom="8dp" 717 android:text="3.3 听力:若平时佩戴助听器,应在佩戴助听器的情况下评估" 718 android:textSize="16sp"/> 719 <RadioGroup 720 android:id="@+id/q3.3" 721 android:layout_width="match_parent" 722 android:layout_height="wrap_content" 723 android:layout_marginLeft="16dp" 724 android:layout_marginBottom="16dp" 725 android:orientation="vertical"> 726 <RadioButton 727 android:layout_width="match_parent" 728 android:layout_height="wrap_content" 729 android:layout_marginBottom="4dp" 730 android:text="可正常交谈,能听到电视、电话、门铃的声音" 731 android:tag="0" 732 android:textSize="14sp"/> 733 <RadioButton 734 android:layout_width="match_parent" 735 android:layout_height="wrap_content" 736 android:layout_marginBottom="4dp" 737 android:text="在轻声说话或说话距离超过2米时听不清" 738 android:tag="1" 739 android:textSize="14sp"/> 740 <RadioButton 741 android:layout_width="match_parent" 742 android:layout_height="wrap_content" 743 android:layout_marginBottom="4dp" 744 android:text="正常交流有些困难,需在安静的环静或大声说话才能听到" 745 android:tag="2" 746 android:textSize="14sp"/> 747 <RadioButton 748 android:layout_width="match_parent" 749 android:layout_height="wrap_content" 750 android:layout_marginBottom="4dp" 751 android:text="讲话者大声说话或说话很慢,才能部分听见" 752 android:tag="3" 753 android:textSize="14sp"/> 754 <RadioButton 755 android:layout_width="match_parent" 756 android:layout_height="wrap_content" 757 android:text="完全听不见" 758 android:tag="4" 759 android:textSize="14sp"/> 760 </RadioGroup> 761 762 <View 763 android:layout_width="match_parent" 764 android:layout_height="1dp" 765 android:layout_marginVertical="8dp" 766 android:background="#E0E0E0"/> 767 768 <TextView 769 android:layout_width="match_parent" 770 android:layout_height="wrap_content" 771 android:layout_marginBottom="8dp" 772 android:text="3.4 沟通交流: 包括非语言沟通" 773 android:textSize="16sp"/> 774 <RadioGroup 775 android:id="@+id/q3.4" 776 android:layout_width="match_parent" 777 android:layout_height="wrap_content" 778 android:layout_marginLeft="16dp" 779 android:layout_marginBottom="16dp" 780 android:orientation="vertical"> 781 <RadioButton 782 android:layout_width="match_parent" 783 android:layout_height="wrap_content" 784 android:layout_marginBottom="4dp" 785 android:text="无困难,能与他人正常沟通和交流" 786 android:tag="0" 787 android:textSize="14sp"/> 788 <RadioButton 789 android:layout_width="match_parent" 790 android:layout_height="wrap_content" 791 android:layout_marginBottom="4dp" 792 android:text="能够表达自己的需要及理解别人的话,但需要增加时间或给予帮助" 793 android:tag="1" 794 android:textSize="14sp"/> 795 <RadioButton 796 android:layout_width="match_parent" 797 android:layout_height="wrap_content" 798 android:layout_marginBottom="4dp" 799 android:text="表达需要或理解有困难,需频繁重复或简化口头表达" 800 android:tag="2" 801 android:textSize="14sp"/> 802 <RadioButton 803 android:layout_width="match_parent" 804 android:layout_height="wrap_content" 805 android:text="不能表达需要或理解他人的话" 806 android:tag="3" 807 android:textSize="14sp"/> 808 </RadioGroup> 809 810 <Button 811 android:id="@+id/SCbtn" 812 android:onClick="SCbtn" 813 android:layout_width="match_parent" 814 android:layout_height="48dp" 815 android:backgroundTint="#03A9F4" 816 android:text="提交" 817 android:textColor="#FFFFFF"/> 818 </LinearLayout> 819 820 <LinearLayout 821 android:id="@+id/SI" 822 android:layout_width="match_parent" 823 android:layout_height="wrap_content" 824 android:orientation="vertical" 825 android:visibility="gone"> 826 827 <TextView 828 android:layout_width="match_parent" 829 android:layout_height="wrap_content" 830 android:layout_marginBottom="8dp" 831 android:text="4.1 生活能力" 832 android:textSize="16sp"/> 833 <RadioGroup 834 android:id="@+id/q4.1" 835 android:layout_width="match_parent" 836 android:layout_height="wrap_content" 837 android:layout_marginLeft="16dp" 838 android:layout_marginBottom="16dp" 839 android:orientation="vertical"> 840 <RadioButton 841 android:layout_width="match_parent" 842 android:layout_height="wrap_content" 843 android:layout_marginBottom="4dp" 844 android:text="除个人生活自理外(如饮食、洗漱、穿戴、二便),能料理家务(如做饭、洗衣)或当家管理事务" 845 android:tag="0" 846 android:textSize="14sp"/> 847 <RadioButton 848 android:layout_width="match_parent" 849 android:layout_height="wrap_content" 850 android:layout_marginBottom="4dp" 851 android:text="除个人生活自理外,能做家务,但欠好,家庭事务安排欠条理" 852 android:tag="1" 853 android:textSize="14sp"/> 854 <RadioButton 855 android:layout_width="match_parent" 856 android:layout_height="wrap_content" 857 android:layout_marginBottom="4dp" 858 android:text="个人生活能自理;只有在他人帮助下才能做些家务,但质量不好" 859 android:tag="2" 860 android:textSize="14sp"/> 861 <RadioButton 862 android:layout_width="match_parent" 863 android:layout_height="wrap_content" 864 android:layout_marginBottom="4dp" 865 android:text="个人基本生活事务能自理(如饮食、二便),在督促下可洗漱" 866 android:tag="3" 867 android:textSize="14sp"/> 868 <RadioButton 869 android:layout_width="match_parent" 870 android:layout_height="wrap_content" 871 android:text="个人基本生活事务(如饮食、二便)需要部分帮助或完全依赖他人帮助" 872 android:tag="4" 873 android:textSize="14sp"/> 874 </RadioGroup> 875 876 <View 877 android:layout_width="match_parent" 878 android:layout_height="1dp" 879 android:layout_marginVertical="8dp" 880 android:background="#E0E0E0"/> 881 882 <TextView 883 android:layout_width="match_parent" 884 android:layout_height="wrap_content" 885 android:layout_marginBottom="8dp" 886 android:text="4.2 工作能力" 887 android:textSize="16sp"/> 888 <RadioGroup 889 android:id="@+id/q4.2" 890 android:layout_width="match_parent" 891 android:layout_height="wrap_content" 892 android:layout_marginLeft="16dp" 893 android:layout_marginBottom="16dp" 894 android:orientation="vertical"> 895 <RadioButton 896 android:layout_width="match_parent" 897 android:layout_height="wrap_content" 898 android:layout_marginBottom="4dp" 899 android:text="原来熟练的脑力工作或体力技巧性工作可照常进行" 900 android:tag="0" 901 android:textSize="14sp"/> 902 <RadioButton 903 android:layout_width="match_parent" 904 android:layout_height="wrap_content" 905 android:layout_marginBottom="4dp" 906 android:text="原来熟练的脑力工作或体力技巧性工作能力有所下降" 907 android:tag="1" 908 android:textSize="14sp"/> 909 <RadioButton 910 android:layout_width="match_parent" 911 android:layout_height="wrap_content" 912 android:layout_marginBottom="4dp" 913 android:text="原来熟练的脑力工作或体力技巧性工作明显不如以往,部分遗忘" 914 android:tag="2" 915 android:textSize="14sp"/> 916 <RadioButton 917 android:layout_width="match_parent" 918 android:layout_height="wrap_content" 919 android:layout_marginBottom="4dp" 920 android:text="对熟练工作只有一些片段保留,技能全部遗忘" 921 android:tag="3" 922 android:textSize="14sp"/> 923 <RadioButton 924 android:layout_width="match_parent" 925 android:layout_height="wrap_content" 926 android:text="对以往的知识或技能全部磨灭" 927 android:tag="4" 928 android:textSize="14sp"/> 929 </RadioGroup> 930 931 <View 932 android:layout_width="match_parent" 933 android:layout_height="1dp" 934 android:layout_marginVertical="8dp" 935 android:background="#E0E0E0"/> 936 937 <TextView 938 android:layout_width="match_parent" 939 android:layout_height="wrap_content" 940 android:layout_marginBottom="8dp" 941 android:text="4.3 时间/空间定向" 942 android:textSize="16sp"/> 943 <RadioGroup 944 android:id="@+id/q4.3" 945 android:layout_width="match_parent" 946 android:layout_height="wrap_content" 947 android:layout_marginLeft="16dp" 948 android:layout_marginBottom="16dp" 949 android:orientation="vertical"> 950 <RadioButton 951 android:layout_width="match_parent" 952 android:layout_height="wrap_content" 953 android:layout_marginBottom="4dp" 954 android:text="时间观念(年、月、日、时)清楚;可单独出远门,能很快掌握新环境的方位" 955 android:tag="0" 956 android:textSize="14sp"/> 957 <RadioButton 958 android:layout_width="match_parent" 959 android:layout_height="wrap_content" 960 android:layout_marginBottom="4dp" 961 android:text="时间观念有些下降,年、月、日清楚,但有时相差几天;可单独来往于近街,知道现住地的名称和方位,但不知回家路线" 962 android:tag="1" 963 android:textSize="14sp"/> 964 <RadioButton 965 android:layout_width="match_parent" 966 android:layout_height="wrap_content" 967 android:layout_marginBottom="4dp" 968 android:text="时间观念较差,年、月、日不清楚,可知上半年或下半年;只能单独在家附近行动,对现住地只知名称,不知道方位" 969 android:tag="2" 970 android:textSize="14sp"/> 971 <RadioButton 972 android:layout_width="match_parent" 973 android:layout_height="wrap_content" 974 android:layout_marginBottom="4dp" 975 android:text="时间观念很差,年、月、日不清楚,可知上午或下午;只能在左邻右舍间串门,对现住地不知名称和方位" 976 android:tag="3" 977 android:textSize="14sp"/> 978 <RadioButton 979 android:layout_width="match_parent" 980 android:layout_height="wrap_content" 981 android:text="无时间观念;不能单独外出" 982 android:tag="4" 983 android:textSize="14sp"/> 984 </RadioGroup> 985 986 <View 987 android:layout_width="match_parent" 988 android:layout_height="1dp" 989 android:layout_marginVertical="8dp" 990 android:background="#E0E0E0"/> 991 992 <TextView 993 android:layout_width="match_parent" 994 android:layout_height="wrap_content" 995 android:layout_marginBottom="8dp" 996 android:text="4.4 人物定向" 997 android:textSize="16sp"/> 998 <RadioGroup 999 android:id="@+id/q4.4" 1000 android:layout_width="match_parent" 1001 android:layout_height="wrap_content" 1002 android:layout_marginLeft="16dp" 1003 android:layout_marginBottom="16dp" 1004 android:orientation="vertical"> 1005 <RadioButton 1006 android:layout_width="match_parent" 1007 android:layout_height="wrap_content" 1008 android:layout_marginBottom="4dp" 1009 android:text="知道周围人们的关系,知道祖孙、叔伯、姑姨、侄子侄女等称谓的意义;可分辨陌生人的大致年龄和身份,可用适当称呼" 1010 android:tag="0" 1011 android:textSize="14sp"/> 1012 <RadioButton 1013 android:layout_width="match_parent" 1014 android:layout_height="wrap_content" 1015 android:layout_marginBottom="4dp" 1016 android:text="只知家中亲密近亲的关系,不会分辨陌生人的大致年龄,不能称呼陌生人" 1017 android:tag="1" 1018 android:textSize="14sp"/> 1019 <RadioButton 1020 android:layout_width="match_parent" 1021 android:layout_height="wrap_content" 1022 android:layout_marginBottom="4dp" 1023 android:text="只能称呼家中人,或只能照样称呼,不知其关系,不辨辈分" 1024 android:tag="2" 1025 android:textSize="14sp"/> 1026 <RadioButton 1027 android:layout_width="match_parent" 1028 android:layout_height="wrap_content" 1029 android:layout_marginBottom="4dp" 1030 android:text="只认识常同住的亲人,可称呼子女或孙子女,可辨熟人和生人" 1031 android:tag="3" 1032 android:textSize="14sp"/> 1033 <RadioButton 1034 android:layout_width="match_parent" 1035 android:layout_height="wrap_content" 1036 android:text="只认识保护人,不辨熟人和生人" 1037 android:tag="4" 1038 android:textSize="14sp"/> 1039 </RadioGroup> 1040 1041 <View 1042 android:layout_width="match_parent" 1043 android:layout_height="1dp" 1044 android:layout_marginVertical="8dp" 1045 android:background="#E0E0E0"/> 1046 1047 <TextView 1048 android:layout_width="match_parent" 1049 android:layout_height="wrap_content" 1050 android:layout_marginBottom="8dp" 1051 android:text="4.5 社会交往能力" 1052 android:textSize="16sp"/> 1053 <RadioGroup 1054 android:id="@+id/q4.5" 1055 android:layout_width="match_parent" 1056 android:layout_height="wrap_content" 1057 android:layout_marginLeft="16dp" 1058 android:layout_marginBottom="16dp" 1059 android:orientation="vertical"> 1060 <RadioButton 1061 android:layout_width="match_parent" 1062 android:layout_height="wrap_content" 1063 android:layout_marginBottom="4dp" 1064 android:text="参与社会,在社会环境有一定的适应能力,待人接物恰当" 1065 android:tag="0" 1066 android:textSize="14sp"/> 1067 <RadioButton 1068 android:layout_width="match_parent" 1069 android:layout_height="wrap_content" 1070 android:layout_marginBottom="4dp" 1071 android:text="能适应单纯环境,主动接触人,初见面时难让人发现智力问题,不能理解隐喻语" 1072 android:tag="1" 1073 android:textSize="14sp"/> 1074 <RadioButton 1075 android:layout_width="match_parent" 1076 android:layout_height="wrap_content" 1077 android:layout_marginBottom="4dp" 1078 android:text="脱离社会,可被动接触,不会主动待人,谈话中很多不适词句,容易上当受骗" 1079 android:tag="2" 1080 android:textSize="14sp"/> 1081 <RadioButton 1082 android:layout_width="match_parent" 1083 android:layout_height="wrap_content" 1084 android:layout_marginBottom="4dp" 1085 android:text="勉强可与人交往,谈吐内容不清楚,表情不恰当" 1086 android:tag="3" 1087 android:textSize="14sp"/> 1088 <RadioButton 1089 android:layout_width="match_parent" 1090 android:layout_height="wrap_content" 1091 android:text="难以与人接触" 1092 android:tag="4" 1093 android:textSize="14sp"/> 1094 </RadioGroup> 1095 1096 <Button 1097 android:id="@+id/SIbtn" 1098 android:onClick="SIbtn" 1099 android:layout_width="match_parent" 1100 android:layout_height="48dp" 1101 android:backgroundTint="#03A9F4" 1102 android:text="提交" 1103 android:textColor="#FFFFFF"/> 1104 </LinearLayout> 1105 </LinearLayout> 1106 </ScrollView> 1107 </LinearLayout>
TestActivity.class
1 package com.app; 2 3 import android.content.Intent; 4 import android.content.SharedPreferences; 5 import android.os.Bundle; 6 import android.view.View; 7 import android.widget.Button; 8 import android.widget.EditText; 9 import android.widget.LinearLayout; 10 import android.widget.RadioButton; 11 import android.widget.RadioGroup; 12 import android.widget.TextView; 13 import android.widget.Toast; 14 15 import androidx.appcompat.app.AppCompatActivity; 16 17 import com.app.api.AbilityService; 18 19 import java.util.ArrayList; 20 21 import okhttp3.ResponseBody; 22 import retrofit2.Call; 23 import retrofit2.Callback; 24 import retrofit2.Response; 25 import retrofit2.Retrofit; 26 import retrofit2.converter.gson.GsonConverterFactory; 27 28 public class TestActivity extends AppCompatActivity { 29 30 Retrofit retrofit; 31 AbilityService abilityService; 32 33 private String id; 34 35 private TextView title; 36 private Button dlbtn; 37 private Button msbtn; 38 private Button scbtn; 39 private Button sibtn; 40 private LinearLayout dl; 41 private LinearLayout ms; 42 private LinearLayout sc; 43 private LinearLayout si; 44 45 private ArrayList<RadioGroup> dlList = new ArrayList<>(); 46 private ArrayList<RadioGroup> msList = new ArrayList<>(); 47 private ArrayList<RadioGroup> scList = new ArrayList<>(); 48 private ArrayList<RadioGroup> siList = new ArrayList<>(); 49 50 private EditText et2_1,et2_2,et2_3; 51 52 @Override 53 protected void onCreate(Bundle savedInstanceState) { 54 super.onCreate(savedInstanceState); 55 setContentView(R.layout.activity_test); 56 57 initView(); 58 59 retrofit = new Retrofit.Builder() 60 .baseUrl("http://192.168.0.2:8080") 61 .addConverterFactory(GsonConverterFactory.create()) 62 .build(); 63 abilityService = retrofit.create(AbilityService.class); 64 65 SharedPreferences sp = getSharedPreferences("userInfo",MODE_PRIVATE); 66 id = sp.getString("id",""); 67 } 68 69 public void initView(){ 70 title = findViewById(R.id.title); 71 72 dlbtn = findViewById(R.id.DLbtn); 73 msbtn = findViewById(R.id.MSbtn); 74 scbtn = findViewById(R.id.SCbtn); 75 sibtn = findViewById(R.id.SIbtn); 76 dl = findViewById(R.id.DL); 77 ms = findViewById(R.id.MS); 78 sc = findViewById(R.id.SC); 79 si = findViewById(R.id.SI); 80 81 dlList.add(findViewById(R.id.q1_1)); 82 dlList.add(findViewById(R.id.q1_2)); 83 dlList.add(findViewById(R.id.q1_3)); 84 dlList.add(findViewById(R.id.q1_4)); 85 dlList.add(findViewById(R.id.q1_5)); 86 dlList.add(findViewById(R.id.q1_6)); 87 dlList.add(findViewById(R.id.q1_7)); 88 dlList.add(findViewById(R.id.q1_8)); 89 dlList.add(findViewById(R.id.q1_9)); 90 dlList.add(findViewById(R.id.q1_10)); 91 92 et2_1 = findViewById(R.id.et2_1_1); 93 et2_2 = findViewById(R.id.et2_1_2); 94 et2_3 = findViewById(R.id.et2_1_3); 95 msList.add(findViewById(R.id.q2_2)); 96 msList.add(findViewById(R.id.q2_3)); 97 98 scList.add(findViewById(R.id.q3_1)); 99 scList.add(findViewById(R.id.q3_2)); 100 scList.add(findViewById(R.id.q3_3)); 101 scList.add(findViewById(R.id.q3_4)); 102 103 siList.add(findViewById(R.id.q4_1)); 104 siList.add(findViewById(R.id.q4_2)); 105 siList.add(findViewById(R.id.q4_3)); 106 siList.add(findViewById(R.id.q4_4)); 107 siList.add(findViewById(R.id.q4_5)); 108 } 109 110 private int getTotalScore(ArrayList<RadioGroup> list) { 111 int score = 0; 112 for (RadioGroup rg : list) { 113 int checkedId = rg.getCheckedRadioButtonId(); 114 if (checkedId == -1) 115 return -1; 116 score += Integer.parseInt(((RadioButton) rg.findViewById(checkedId)).getTag().toString()); 117 } 118 return score; 119 } 120 121 122 private int getRadioTotalScore(ArrayList<RadioGroup> list) { 123 int score = 0; 124 for (RadioGroup rg : list) { 125 int checkedId = rg.getCheckedRadioButtonId(); 126 if (checkedId == -1) return -1; 127 score += Integer.parseInt(((RadioButton) rg.findViewById(checkedId)).getTag().toString()); 128 } 129 return score; 130 } 131 132 private int getRadioValue(RadioGroup rg) { 133 int checkedId = rg.getCheckedRadioButtonId(); 134 if (checkedId == -1) return -1; 135 return Integer.parseInt(((RadioButton) rg.findViewById(checkedId)).getTag().toString()); 136 } 137 138 public void DLbtn(View view) { 139 int score1 = getRadioTotalScore(dlList); 140 if (score1 == -1) { 141 Toast.makeText(this, "此页面未填写完整", Toast.LENGTH_SHORT).show(); 142 return; 143 } 144 145 int level1 = 3; 146 if (score1 == 100) level1 = 0; 147 else if (score1 >= 65 && score1 <= 95) level1 = 1; 148 else if (score1 >= 45 && score1 <= 60) level1 = 2; 149 150 abilityService.updateActivityOfDailyLiving(id, level1, score1).enqueue(new Callback<ResponseBody>() { 151 @Override 152 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 153 dlbtn.setVisibility(View.GONE); 154 dl.setVisibility(View.GONE); 155 msbtn.setVisibility(View.VISIBLE); 156 ms.setVisibility(View.VISIBLE); 157 title.setText(R.string.MS); 158 159 } 160 @Override 161 public void onFailure(Call<ResponseBody> call, Throwable t) { 162 Toast.makeText(TestActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); 163 } 164 }); 165 } 166 167 public void MSbtn(View view) { 168 String word1 = et2_1.getText().toString().trim(); 169 String word2 = et2_2.getText().toString().trim(); 170 String word3 = et2_3.getText().toString().trim(); 171 172 if (word1.isEmpty() || word2.isEmpty() || word3.isEmpty() 173 || word1.equals(word2) || word1.equals(word3) || word2.equals(word3)) { 174 Toast.makeText(this, "回忆词语有空值或重复,请重新填写", Toast.LENGTH_SHORT).show(); 175 return; 176 } 177 int score2 = 2; 178 String[] words = {"苹果", "手表", "国旗"}; 179 180 if (word1.equals(words[0]) || word1.equals(words[1]) || word1.equals(words[2])) { 181 score2--; 182 } 183 if (word2.equals(words[0]) || word2.equals(words[1]) || word2.equals(words[2])) { 184 score2--; 185 } 186 if (word3.equals(words[0]) || word3.equals(words[1]) || word3.equals(words[2])) { 187 score2--; 188 } 189 if (score2 < 0) score2 = 0; 190 int radioScore = getRadioTotalScore(msList); 191 if (radioScore == -1) { 192 Toast.makeText(this, "此页面未填写完整", Toast.LENGTH_SHORT).show(); 193 return; 194 } 195 196 score2 += radioScore; 197 198 int level2; 199 if (score2 == 0) { 200 level2 = 0; 201 } else if (score2 == 1) { 202 level2 = 1; 203 } else if (score2 >= 2 && score2 <= 3) { 204 level2 = 2; 205 } else { 206 level2 = 3; 207 } 208 209 abilityService.updateMentalStatus(id, level2, score2).enqueue(new Callback<ResponseBody>() { 210 @Override 211 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 212 msbtn.setVisibility(View.GONE); 213 ms.setVisibility(View.GONE); 214 scbtn.setVisibility(View.VISIBLE); 215 sc.setVisibility(View.VISIBLE); 216 title.setText(R.string.SC); 217 } 218 219 @Override 220 public void onFailure(Call<ResponseBody> call, Throwable t) { 221 Toast.makeText(TestActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); 222 } 223 }); 224 } 225 226 public void SCbtn(View view) { 227 int aware = getRadioValue(scList.get(0)); 228 int vision = getRadioValue(scList.get(1)); 229 int listen = getRadioValue(scList.get(2)); 230 int talk = getRadioValue(scList.get(3)); 231 232 if (aware == -1 || vision == -1 || listen == -1 || talk == -1) { 233 Toast.makeText(this, "请完成所有选项", Toast.LENGTH_SHORT).show(); 234 return; 235 } 236 237 int score3 = aware + vision + listen + talk; 238 239 int level = 3; 240 if (aware == 3) level = 3; 241 else if (aware == 0 && vision <= 1 && listen <= 1 && talk == 0) level = 0; 242 else if (aware == 0 && (vision == 2 || listen == 2 || talk == 1)) level = 1; 243 else if ((aware == 0 && (vision == 3 || listen == 3 || talk == 2)) 244 || (aware == 1 && vision <= 3 && listen <= 3 && talk <= 2)) level = 2; 245 246 abilityService.updateSensoryAndCommunication(id, level, score3).enqueue(new Callback<ResponseBody>() { 247 @Override 248 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 249 scbtn.setVisibility(View.GONE); 250 sc.setVisibility(View.GONE); 251 sibtn.setVisibility(View.VISIBLE); 252 si.setVisibility(View.VISIBLE); 253 title.setText(R.string.SI); 254 } 255 @Override 256 public void onFailure(Call<ResponseBody> call, Throwable t) { 257 Toast.makeText(TestActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); 258 } 259 }); 260 } 261 262 public void SIbtn(View view) { 263 int score4 = getRadioTotalScore(siList); 264 if (score4 == -1) { 265 Toast.makeText(this, "此页面未填写完整", Toast.LENGTH_SHORT).show(); 266 return; 267 } 268 269 int level4 = 3; 270 if (score4 <= 2) level4 = 0; 271 else if (score4 >= 3 && score4 <= 7) level4 = 1; 272 else if (score4 >= 8 && score4 <= 13) level4 = 2; 273 274 abilityService.updateSocialInvolvement(id, level4, score4).enqueue(new Callback<ResponseBody>() { 275 @Override 276 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 277 abilityService.updateInitialScore(id).enqueue(new Callback<ResponseBody>() { 278 @Override 279 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {} 280 281 @Override 282 public void onFailure(Call<ResponseBody> call, Throwable t) {} 283 }); 284 abilityService.updateFinalScore(id).enqueue(new Callback<ResponseBody>() { 285 @Override 286 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {} 287 @Override 288 public void onFailure(Call<ResponseBody> call, Throwable t) {} 289 }); 290 abilityService.updateDate(id).enqueue(new Callback<ResponseBody>() { 291 @Override 292 public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {} 293 @Override 294 public void onFailure(Call<ResponseBody> call, Throwable t) {} 295 }); 296 Toast.makeText(TestActivity.this, "测试完成,感谢您的参与!请前往报告页面查看结果。", Toast.LENGTH_LONG).show(); 297 startActivity(new Intent(TestActivity.this,HomeActivity.class)); 298 } 299 @Override 300 public void onFailure(Call<ResponseBody> call, Throwable t) { 301 Toast.makeText(TestActivity.this, "网络错误", Toast.LENGTH_SHORT).show(); 302 } 303 }); 304 } 305 306 }
activity_report.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical"> 7 <TextView 8 android:layout_width="match_parent" 9 android:layout_height="60dp" 10 android:background="#03A9F4" 11 android:gravity="center" 12 android:text="@string/SystemTitle" 13 android:textColor="#FFFFFF" 14 android:textSize="30sp"/> 15 <TextView 16 android:layout_width="match_parent" 17 android:layout_height="30dp" 18 android:text="@string/reportPage" 19 android:background="#03A9D4" 20 android:gravity="center_vertical" 21 android:paddingLeft="10dp"/> 22 23 <ScrollView 24 android:layout_width="match_parent" 25 android:layout_height="match_parent" 26 android:padding="16dp"> 27 28 <!-- 核心修复:ScrollView内只套一个LinearLayout --> 29 <LinearLayout 30 android:layout_width="match_parent" 31 android:layout_height="wrap_content" 32 android:orientation="vertical"> 33 34 <TableLayout 35 android:layout_width="match_parent" 36 android:layout_height="wrap_content" 37 android:stretchColumns="*" 38 android:shrinkColumns="*"> 39 40 <TableRow> 41 <TextView 42 android:layout_width="wrap_content" 43 android:layout_height="wrap_content" 44 android:layout_span="3" 45 android:background="#f0f0f0" 46 android:padding="10dp" 47 android:text="老年人能力评估报告" 48 android:textAlignment="center" 49 android:textSize="18sp" 50 android:textStyle="bold" /> 51 </TableRow> 52 53 <TableRow> 54 <TextView 55 android:layout_width="wrap_content" 56 android:layout_height="wrap_content" 57 android:layout_span="1" 58 android:layout_rowSpan="2" 59 android:background="#f0f0f0" 60 android:padding="10dp" 61 android:text="一级指标\n分级" 62 android:textAlignment="center" /> 63 64 <TextView 65 android:id="@+id/tv_dl_level" 66 android:layout_width="wrap_content" 67 android:layout_height="wrap_content" 68 android:padding="10dp" 69 android:text="日常生活活动:级" /> 70 71 <TextView 72 android:id="@+id/tv_ms_level" 73 android:layout_width="wrap_content" 74 android:layout_height="wrap_content" 75 android:padding="10dp" 76 android:text="精神状态:级" /> 77 </TableRow> 78 79 <TableRow> 80 <TextView 81 android:id="@+id/tv_sc_level" 82 android:layout_width="wrap_content" 83 android:layout_height="wrap_content" 84 android:padding="10dp" 85 android:text="感知觉与沟通:级" /> 86 87 <TextView 88 android:id="@+id/tv_si_level" 89 android:layout_width="wrap_content" 90 android:layout_height="wrap_content" 91 android:padding="10dp" 92 android:text="社会参与:级" /> 93 </TableRow> 94 95 <TableRow> 96 <TextView 97 android:layout_width="wrap_content" 98 android:layout_height="wrap_content" 99 android:background="#f0f0f0" 100 android:padding="10dp" 101 android:text="老年人能力初步等级" 102 android:textAlignment="center" /> 103 104 <TextView 105 android:id="@+id/tv_initial_score" 106 android:layout_width="wrap_content" 107 android:layout_height="wrap_content" 108 android:layout_span="2" 109 android:padding="10dp" 110 android:text=" " /> 111 </TableRow> 112 113 <TableRow> 114 <TextView 115 android:layout_width="wrap_content" 116 android:layout_height="wrap_content" 117 android:background="#f0f0f0" 118 android:padding="10dp" 119 android:text="等级变更条款" 120 android:textAlignment="center" /> 121 122 <TextView 123 android:layout_width="wrap_content" 124 android:layout_height="wrap_content" 125 android:layout_span="2" 126 android:padding="10dp" 127 android:text="1 有认知障碍/痴呆、精神疾病者,在原有能力级别上提高一个等级;\n2 近30天内发生过2次及以上跌倒、噎食、自杀、走失者,在原有能力级别上提高一个等级;\n3 处于昏迷状态者,直接评定为重度失能;\n4 若初步等级确定为“3 重度失能”,则不考虑上述1-3中各情况对最终等级的影响,等级不再提高" 128 android:textAlignment="viewStart" /> 129 </TableRow> 130 131 <TableRow> 132 <TextView 133 android:layout_width="wrap_content" 134 android:layout_height="wrap_content" 135 android:background="#f0f0f0" 136 android:padding="10dp" 137 android:text="老年人能力最终等级" 138 android:textAlignment="center" /> 139 140 <TextView 141 android:id="@+id/tv_final_score" 142 android:layout_width="wrap_content" 143 android:layout_height="wrap_content" 144 android:layout_span="2" 145 android:padding="10dp" 146 android:text=" " /> 147 </TableRow> 148 149 <TableRow> 150 <TextView 151 android:id="@+id/tv_sign_info" 152 android:layout_width="wrap_content" 153 android:layout_height="wrap_content" 154 android:layout_span="3" 155 android:padding="10dp" 156 android:text="信息提供者签名 日期 " /> 157 </TableRow> 158 159 <TableRow> 160 <TextView 161 android:layout_width="wrap_content" 162 android:layout_height="wrap_content" 163 android:layout_span="3" 164 android:padding="10dp" 165 android:text=" 166 注:老年人能力初步等级划分标准 167 168 0 能力完好: 169 日常生活活动、精神状态、感知觉与沟通分级均为0,社会参与分级为0或1 170 171 1 轻度失能: 172 日常生活活动分级为0,但精神状态、感知觉与沟通中至少一项分级为1及以上,或社会参与的分级为2; 173 或日常生活活动分级为1,精神状态、感知觉与沟通、社会参与中至少有一项的分级为0或1 174 175 2 中度失能: 176 日常生活活动分级为1,但精神状态、感知觉与沟通、社会参与均为2,或有一项为3; 177 或日常生活活动分级为2,且精神状态、感知觉与沟通、社会参与中有1-2项的分级为1或2 178 179 3 重度失能: 180 日常生活活动的分级为3; 181 或日常生活活动、精神状态、感知觉与沟通、社会参与分级均为2; 182 或日常生活活动分级为2,且精神状态、感知觉与沟通、社会参与中至少有一项分级为3 183 " 184 android:textSize="12sp" 185 android:textAlignment="viewStart" /> 186 </TableRow> 187 </TableLayout> 188 189 <Button 190 android:id="@+id/btn_back_home" 191 android:layout_width="wrap_content" 192 android:layout_height="wrap_content" 193 android:layout_gravity="center" 194 android:layout_marginTop="20dp" 195 android:backgroundTint="#03A9F4" 196 android:text="返回首页" /> 197 198 </LinearLayout> 199 </ScrollView> 200 </LinearLayout>
ReportActivity.class
1 package com.app; 2 3 import android.content.Intent; 4 import android.content.SharedPreferences; 5 import android.os.Bundle; 6 import android.text.format.DateFormat; 7 import android.widget.TextView; 8 import android.widget.Toast; 9 10 import androidx.appcompat.app.AppCompatActivity; 11 12 import com.app.Entity.Ability; 13 import com.app.Entity.User; 14 import com.app.api.AbilityService; 15 import com.app.api.UserService; 16 17 import java.util.Date; 18 19 import retrofit2.Call; 20 import retrofit2.Callback; 21 import retrofit2.Response; 22 import retrofit2.Retrofit; 23 import retrofit2.converter.gson.GsonConverterFactory; 24 25 public class ReportActivity extends AppCompatActivity { 26 27 private String[] abilityText = {"能力完好", "轻度失能", "中度失能", "重度失能"}; 28 private Retrofit retrofit; 29 private AbilityService abilityService; 30 private UserService userService; 31 private String userId; 32 33 private TextView tvDlLevel, tvMsLevel, tvScLevel, tvSiLevel; 34 private TextView tvInitialScore, tvFinalScore, tvSignInfo; 35 36 @Override 37 protected void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 setContentView(R.layout.activity_report); 40 41 initView(); 42 43 retrofit = new Retrofit.Builder() 44 .baseUrl("http://192.168.0.2:8080") 45 .addConverterFactory(GsonConverterFactory.create()) 46 .build(); 47 abilityService = retrofit.create(AbilityService.class); 48 userService = retrofit.create(UserService.class); 49 50 SharedPreferences sp = getSharedPreferences("userInfo", MODE_PRIVATE); 51 userId = sp.getString("id", ""); 52 if (userId.isEmpty()) { 53 Toast.makeText(this, "用户ID为空,请重新登录", Toast.LENGTH_SHORT).show(); 54 finish(); 55 return; 56 } 57 58 getUserInfo(); 59 getAbilityData(); 60 61 findViewById(R.id.btn_back_home).setOnClickListener(v -> { 62 startActivity(new Intent(ReportActivity.this, HomeActivity.class)); 63 finish(); 64 }); 65 } 66 67 private void initView() { 68 tvDlLevel = findViewById(R.id.tv_dl_level); 69 tvMsLevel = findViewById(R.id.tv_ms_level); 70 tvScLevel = findViewById(R.id.tv_sc_level); 71 tvSiLevel = findViewById(R.id.tv_si_level); 72 tvInitialScore = findViewById(R.id.tv_initial_score); 73 tvFinalScore = findViewById(R.id.tv_final_score); 74 tvSignInfo = findViewById(R.id.tv_sign_info); 75 } 76 77 private void getUserInfo() { 78 userService.getInfo(userId).enqueue(new Callback<User>() { 79 @Override 80 public void onResponse(Call<User> call, Response<User> response) { 81 if (response.isSuccessful() && response.body() != null) { 82 User user = response.body(); 83 tvSignInfo.setText("信息提供者签名 " + user.getName() + " 日期 "); 84 } 85 } 86 87 @Override 88 public void onFailure(Call<User> call, Throwable t) { 89 Toast.makeText(ReportActivity.this, "获取用户信息失败", Toast.LENGTH_SHORT).show(); 90 } 91 }); 92 } 93 94 private void getAbilityData() { 95 abilityService.getAbility(userId).enqueue(new Callback<Ability>() { 96 @Override 97 public void onResponse(Call<Ability> call, Response<Ability> response) { 98 if (response.isSuccessful() && response.body() != null) { 99 Ability ability = response.body(); 100 101 Date date = ability.getDate(); 102 if (date == null) { 103 Toast.makeText(ReportActivity.this, "暂无评估报告,请先完成能力评估问卷", Toast.LENGTH_SHORT).show(); 104 startActivity(new Intent(ReportActivity.this, HomeActivity.class)); 105 finish(); 106 return; 107 } 108 109 tvDlLevel.setText("日常生活活动:" + ability.getActivityOfDailyLiving() + "级"); 110 tvMsLevel.setText("精神状态:" + ability.getMentalStatus() + "级"); 111 tvScLevel.setText("感知觉与沟通:" + ability.getSensoryAndCommunication() + "级"); 112 tvSiLevel.setText("社会参与:" + ability.getSocialInvolvement() + "级"); 113 114 int initialScore = ability.getInitialScore(); 115 tvInitialScore.setText(initialScore + " " + (initialScore >= 0 && initialScore <= 3 ? abilityText[initialScore] : "")); 116 117 int finalScore = ability.getFinalScore(); 118 tvFinalScore.setText(finalScore + " " + (finalScore >= 0 && finalScore <= 3 ? abilityText[finalScore] : "")); 119 120 String dateStr = DateFormat.format("yyyy-MM-dd", date).toString(); 121 tvSignInfo.setText(tvSignInfo.getText().toString().replace("日期 ", "日期 " + dateStr)); 122 } 123 } 124 125 @Override 126 public void onFailure(Call<Ability> call, Throwable t) { 127 Toast.makeText(ReportActivity.this, "获取评估报告失败:" + t.getMessage(), Toast.LENGTH_SHORT).show(); 128 } 129 }); 130 } 131 }
然后是...
AbilityService
1 package com.app.api; 2 3 import com.app.Entity.Ability; 4 5 import okhttp3.ResponseBody; 6 import retrofit2.Call; 7 import retrofit2.http.Field; 8 import retrofit2.http.FormUrlEncoded; 9 import retrofit2.http.GET; 10 import retrofit2.http.POST; 11 import retrofit2.http.Query; 12 13 public interface AbilityService { 14 15 @POST("/ability/addAbility") 16 @FormUrlEncoded 17 Call<ResponseBody> addAbility(@Field("id") String id); 18 19 @POST("/ability/updateActivityOfDailyLiving") 20 @FormUrlEncoded 21 Call<ResponseBody> updateActivityOfDailyLiving( 22 @Field("id") String id, 23 @Field("activityOfDailyLiving") int activityOfDailyLiving, 24 @Field("activityOfDailyLivingScore") int activityOfDailyLivingScore 25 ); 26 27 @POST("/ability/updateMentalStatus") 28 @FormUrlEncoded 29 Call<ResponseBody> updateMentalStatus( 30 @Field("id") String id, 31 @Field("mentalStatus") int mentalStatus, 32 @Field("mentalStatusScore") int mentalStatusScore 33 ); 34 35 @POST("/ability/updateSensoryAndCommunication") 36 @FormUrlEncoded 37 Call<ResponseBody> updateSensoryAndCommunication( 38 @Field("id") String id, 39 @Field("sensoryAndCommunication") int sensoryAndCommunication, 40 @Field("sensoryAndCommunicationScore") int sensoryAndCommunicationScore 41 ); 42 43 @POST("/ability/updateSocialInvolvement") 44 @FormUrlEncoded 45 Call<ResponseBody> updateSocialInvolvement( 46 @Field("id") String id, 47 @Field("socialInvolvement") int socialInvolvement, 48 @Field("socialInvolvementScore") int socialInvolvementScore 49 ); 50 51 @POST("/ability/updateInitialScore") 52 @FormUrlEncoded 53 Call<ResponseBody> updateInitialScore(@Field("id") String id); 54 55 @POST("/ability/updateFinalScore") 56 @FormUrlEncoded 57 Call<ResponseBody> updateFinalScore(@Field("id") String id); 58 59 @POST("/ability/updateDate") 60 @FormUrlEncoded 61 Call<ResponseBody> updateDate(@Field("id") String id); 62 63 @GET("/ability/getAbility") 64 Call<Ability> getAbility(@Query("id") String id); 65 }
UseService.class
1 package com.app.api; 2 3 import com.app.Entity.User; 4 5 import okhttp3.ResponseBody; 6 import retrofit2.Call; 7 import retrofit2.http.Body; 8 import retrofit2.http.Field; 9 import retrofit2.http.FormUrlEncoded; 10 import retrofit2.http.GET; 11 import retrofit2.http.POST; 12 import retrofit2.http.PUT; 13 import retrofit2.http.Query; 14 15 public interface UserService { 16 17 @POST("/user/login") 18 @FormUrlEncoded 19 Call<ResponseBody> login(@Field("id") String id,@Field("password") String password); 20 21 @GET("/user/info") 22 Call<User> getInfo(@Query("id") String id); 23 24 @POST("/user/register") 25 @FormUrlEncoded 26 Call<ResponseBody> register(@Field("id") String id,@Field("password") String password); 27 28 @PUT("/user/update") 29 Call<User> update(@Body User user); 30 }

浙公网安备 33010602011771号