use of android.widget.Button in project platform_frameworks_base by android.
the class ListItemFactory method horizontalButtonSlots.
/**
* Create a horizontal linear layout divided into thirds (with some margins
* separating the thirds), filled with buttons into some slots.
* @param context The context.
* @param desiredHeight The height of the LL.
* @param slots Which slots to fill with buttons.
* @return The linear layout.
*/
public static View horizontalButtonSlots(Context context, int desiredHeight, Slot... slots) {
final LinearLayout ll = new LinearLayout(context);
ll.setOrientation(LinearLayout.HORIZONTAL);
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, desiredHeight);
lp.setMargins(10, 0, 10, 0);
lp.weight = 0.33f;
boolean left = false;
boolean middle = false;
boolean right = false;
for (Slot slot : slots) {
switch(slot) {
case Left:
left = true;
break;
case Middle:
middle = true;
break;
case Right:
right = true;
break;
}
}
if (left) {
final Button button = new Button(context);
button.setText("left");
ll.addView(button, lp);
} else {
ll.addView(new View(context), lp);
}
if (middle) {
final Button button = new Button(context);
button.setText("center");
ll.addView(button, lp);
} else {
ll.addView(new View(context), lp);
}
if (right) {
final Button button = new Button(context);
button.setText("right");
ll.addView(button, lp);
} else {
ll.addView(new View(context), lp);
}
return ll;
}
use of android.widget.Button in project platform_frameworks_base by android.
the class ListItemFactory method button.
/**
* Create a button ready to be a list item.
*
* @param position The position within the list.
* @param context The context.
* @param text The text of the button
* @param desiredHeight The desired height of the button
* @return The created view.
*/
public static View button(int position, Context context, String text, int desiredHeight) {
TextView result = new Button(context);
result.setHeight(desiredHeight);
result.setText(text);
final ViewGroup.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
result.setLayoutParams(lp);
result.setId(position);
result.setTag("button");
return result;
}
use of android.widget.Button in project platform_frameworks_base by android.
the class ListItemFactory method twoButtonsSeparatedByFiller.
/**
* Create a view with a button at the top and bottom, with filler in between.
* The filler is sized to take up any space left over within desiredHeight.
*
* @param position The position within the list.
* @param context The context.
* @param desiredHeight The desired height of the entire view.
* @return The created view.
*/
public static View twoButtonsSeparatedByFiller(int position, Context context, int desiredHeight) {
if (desiredHeight < 90) {
throw new IllegalArgumentException("need at least 90 pixels of height " + "to create the two buttons and leave 10 pixels for the filler");
}
final LinearLayout ll = new LinearLayout(context);
ll.setOrientation(LinearLayout.VERTICAL);
final LinearLayout.LayoutParams buttonLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 50);
final Button topButton = new Button(context);
topButton.setLayoutParams(buttonLp);
topButton.setText("top (position " + position + ")");
ll.addView(topButton);
final TextView middleFiller = new TextView(context);
middleFiller.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, desiredHeight - 100));
middleFiller.setText("filler");
ll.addView(middleFiller);
final Button bottomButton = new Button(context);
bottomButton.setLayoutParams(buttonLp);
bottomButton.setText("bottom (position " + position + ")");
ll.addView(bottomButton);
ll.setTag("twoButtons");
return ll;
}
use of android.widget.Button in project platform_frameworks_base by android.
the class MenuLayout method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mButton = new Button(this);
setContentView(mButton);
}
use of android.widget.Button in project platform_frameworks_base by android.
the class PreDrawListener method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.pre_draw_listener);
mFrame = (MyLinearLayout) findViewById(R.id.frame);
Button mGoButton = (Button) findViewById(R.id.go);
mGoButton.setOnClickListener(this);
}
Aggregations