Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <TextView
- android:id="@+id/PlusMinusOneCounterTextView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:text="@string/PlusMinusOneCounterDefaultValue"
- android:textSize="75sp"
- />
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- >
- <Button
- android:id="@+id/PlusOneButton"
- android:layout_gravity="top"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:text="@string/PlusOneButtonText"
- android:gravity="center|top"
- android:textSize="50sp"
- android:background="@android:color/transparent"/>
- <Button
- android:id="@+id/MinusOneButton"
- android:layout_gravity="bottom"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:text="@string/MinusOneButtonText"
- android:gravity="center|bottom"
- android:textSize="50sp"
- android:background="@android:color/transparent"/>
- </LinearLayout>
- </RelativeLayout>
- private void setCounterTextViewValue( Integer _newValue )
- {
- if( m_сounterTextView == null )
- m_сounterTextView = ( TextView ) findViewById( R.id.PlusMinusOneCounterTextView );
- m_сounterTextView.setText( _newValue.toString() );
- }
- Button plusOneButton = ( Button ) findViewById( R.id.PlusOneButton );
- plusOneButton.setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick( View v )
- {
- try
- {
- m_plusMinusOneCounter.increment();
- setCounterTextViewValue( m_plusMinusOneCounter.getValue() );
- }
- catch ( LessThanMinValueException | MoreThanMaxValueException e )
- {
- // Do nothing
- }
- }
- }
- );
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#000000">
Add Comment
Please, Sign In to add comment