Code example for Button

Methods: setCompoundDrawablesWithIntrinsicBoundssetPaddingsetTextsetTextSize, setLayoutParams, setOnClickListener, setTag

0
		}); 
		tabs.add(btn);
	} 
 
	public void addTab(String s, int drawable, int drawablePosition, Context context) {
		final Button btn = new Button(context);
		if(isHorizontal)
			btn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT, 1));
		else 
			btn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
		if(s.length() > 0) {
			btn.setText(s);
			btn.setTextSize(tabFontSize);
			btn.setPadding(0, 2, 0, 8);
		} 
		btn.setTag((Integer)tabs.size());
		switch(drawablePosition) {
		case DRAWABLE_LEFT:
			btn.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0);
			break; 
		case DRAWABLE_TOP:
			btn.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0);
			break; 
		case DRAWABLE_RIGHT:
			btn.setCompoundDrawablesWithIntrinsicBounds(0, 0, drawable, 0);
			break; 
		case DRAWABLE_BOTTOM:
			btn.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, drawable);
			break; 
		} 
		btn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				scrollToScreen((Integer)btn.getTag());
			} 
		}); 
		tabs.add(btn);