Code example for Button

Methods: setTextsetTextSizesetTypeface, setOnClickListener, setOnLongClickListener, setOnTouchListener

0
    valueText.setText( value.toString() );
    valueText.setInputType( InputType.TYPE_CLASS_NUMBER );
  } 
 
  private void initDecrementButton( Context context){
    decrement = new Button( context );
    decrement.setTextSize( mTextSize );
    decrement.setText( " - " );
    decrement.setTypeface(getButtonTypeface());
 
 
    // Decrement once for a click 
    decrement.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
              decrement(); 
            } 
        }); 
 
 
    // Auto Decrement for a long click 
    decrement.setOnLongClickListener(
        new View.OnLongClickListener(){
          public boolean onLongClick(View arg0) {
            autoDecrement = true;
            repeatUpdateHandler.post( new RepetetiveUpdater() );
            return false; 
          } 
        } 
    ); 
 
    // When the button is released, if we're auto decrementing, stop 
    decrement.setOnTouchListener( new View.OnTouchListener() {
      public boolean onTouch(View v, MotionEvent event) {
        if( event.getAction() == MotionEvent.ACTION_UP && autoDecrement ){
          autoDecrement = false;
        } 
        return false;