Search in sources :

Example 56 with Button

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;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) AbsListView(android.widget.AbsListView) LinearLayout(android.widget.LinearLayout)

Example 57 with Button

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;
}
Also used : Button(android.widget.Button) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView)

Example 58 with Button

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;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 59 with Button

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);
}
Also used : Button(android.widget.Button)

Example 60 with Button

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);
}
Also used : Button(android.widget.Button)

Aggregations

Button (android.widget.Button)1477 View (android.view.View)909 TextView (android.widget.TextView)609 OnClickListener (android.view.View.OnClickListener)275 Intent (android.content.Intent)200 LinearLayout (android.widget.LinearLayout)189 ImageView (android.widget.ImageView)146 EditText (android.widget.EditText)126 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)76 ViewGroup (android.view.ViewGroup)65 LayoutInflater (android.view.LayoutInflater)56 CompoundButton (android.widget.CompoundButton)53 ScrollView (android.widget.ScrollView)53 Test (org.junit.Test)51 Bundle (android.os.Bundle)49 CheckBox (android.widget.CheckBox)48 FrameLayout (android.widget.FrameLayout)47 AlertDialog (android.app.AlertDialog)45 ImageButton (android.widget.ImageButton)45