Guest User

Untitled

a guest
Nov 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <android.support.design.widget.TextInputLayout
  2. android:id="@+id/input_layout_provider"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content">
  5.  
  6. <android.support.v7.widget.AppCompatCheckBox
  7. android:id="@+id/input_chk_provider"
  8. android:layout_width="wrap_content"
  9. android:layout_height="wrap_content"
  10. android:checked="false"
  11. android:duplicateParentState="false"
  12. android:text="@string/user_type_provider" />
  13. </android.support.design.widget.TextInputLayout>
  14.  
  15. <Button
  16. android:id="@+id/btn_signup"
  17. android:layout_width="match_parent"
  18. android:layout_height="wrap_content"
  19. android:text="@string/btn_sing_up"
  20. android:background="@color/ic_launcher_background"
  21. android:layout_marginTop="40dp"
  22. android:textColor="@android:color/white"/>
  23.  
  24. <Button
  25. android:id="@+id/btn_provider"
  26. android:layout_width="match_parent"
  27. android:layout_height="wrap_content"
  28. android:text="@string/btn_provider_dtl"
  29. android:background="@color/ic_launcher_background"
  30. android:layout_marginTop="40dp"
  31. android:textColor="@android:color/white"/>
  32.  
  33. checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  34.  
  35. @Override
  36. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  37. if(isChecked) {
  38. btn1.setVisibility(View.GONE);
  39. btn2.setVisibility(View.VISIBLE);
  40. } else {
  41. btn1.setVisibility(View.VISIBLE);
  42. btn2.setVisibility(View.GONE);
  43. }
  44. });
  45.  
  46. CheckBox checkBox = (CheckBox) findViewById(R.id.check1);
  47. Button yourButton = (Button) findViewById(R.id.btn1);
  48.  
  49. checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  50.  
  51. @Override
  52. public void onCheckedChanged(CompoundButton button, boolean isChecked) {
  53. if(isChecked){
  54. yourButton.setVisibility(View.VISIBLE);
  55. } else {
  56. yourButton.setVisibility(View.INVISIBLE);
  57. }
  58. }
  59.  
  60. });
  61.  
  62. View.GONE
  63. View.VISIBLE
  64. View.INVISIBLE
Add Comment
Please, Sign In to add comment