Guest User

Untitled

a guest
Oct 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <RelativeLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. >
  6.  
  7. <TextView
  8. android:id="@+id/PlusMinusOneCounterTextView"
  9. android:layout_width="fill_parent"
  10. android:layout_height="fill_parent"
  11. android:layout_gravity="center"
  12. android:gravity="center"
  13. android:text="@string/PlusMinusOneCounterDefaultValue"
  14. android:textSize="75sp"
  15. />
  16.  
  17. <LinearLayout
  18. xmlns:android="http://schemas.android.com/apk/res/android"
  19. android:layout_width="fill_parent"
  20. android:layout_height="fill_parent"
  21. android:orientation="vertical"
  22. >
  23.  
  24. <Button
  25. android:id="@+id/PlusOneButton"
  26. android:layout_gravity="top"
  27. android:layout_width="fill_parent"
  28. android:layout_height="fill_parent"
  29. android:layout_weight="1"
  30. android:text="@string/PlusOneButtonText"
  31. android:gravity="center|top"
  32. android:textSize="50sp"
  33. android:background="@android:color/transparent"/>
  34.  
  35. <Button
  36. android:id="@+id/MinusOneButton"
  37. android:layout_gravity="bottom"
  38. android:layout_width="fill_parent"
  39. android:layout_height="fill_parent"
  40. android:layout_weight="1"
  41. android:text="@string/MinusOneButtonText"
  42. android:gravity="center|bottom"
  43. android:textSize="50sp"
  44. android:background="@android:color/transparent"/>
  45. </LinearLayout>
  46. </RelativeLayout>
  47.  
  48. private void setCounterTextViewValue( Integer _newValue )
  49. {
  50. if( m_сounterTextView == null )
  51. m_сounterTextView = ( TextView ) findViewById( R.id.PlusMinusOneCounterTextView );
  52.  
  53. m_сounterTextView.setText( _newValue.toString() );
  54. }
  55.  
  56. Button plusOneButton = ( Button ) findViewById( R.id.PlusOneButton );
  57. plusOneButton.setOnClickListener(
  58. new View.OnClickListener() {
  59. @Override
  60. public void onClick( View v )
  61. {
  62. try
  63. {
  64. m_plusMinusOneCounter.increment();
  65. setCounterTextViewValue( m_plusMinusOneCounter.getValue() );
  66.  
  67. }
  68. catch ( LessThanMinValueException | MoreThanMaxValueException e )
  69. {
  70. // Do nothing
  71. }
  72. }
  73. }
  74. );
  75.  
  76. <RelativeLayout
  77. xmlns:android="http://schemas.android.com/apk/res/android"
  78. android:layout_width="fill_parent"
  79. android:layout_height="fill_parent"
  80. android:background="#000000">
Add Comment
Please, Sign In to add comment