Search in sources :

Example 36 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class VerticalFocusSearch method addSkinny.

/**
     * Add a skinny button that takes up just less than half of the screen
     * horizontally.
     * @param root The layout to add the button to.
     * @param label The label of the button.
     * @param atRight Which side to put the button on.
     * @return The newly created button.
     */
private Button addSkinny(LinearLayout root, String label, boolean atRight) {
    Button button = new MyButton(this);
    button.setText(label);
    button.setLayoutParams(new LinearLayout.LayoutParams(// width
    0, ViewGroup.LayoutParams.WRAP_CONTENT, 480));
    TextView filler = new TextView(this);
    filler.setText("filler");
    filler.setLayoutParams(new LinearLayout.LayoutParams(// width
    0, ViewGroup.LayoutParams.WRAP_CONTENT, 520));
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    if (atRight) {
        ll.addView(filler);
        ll.addView(button);
        root.addView(ll);
    } else {
        ll.addView(button);
        ll.addView(filler);
        root.addView(ll);
    }
    return button;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 37 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class FocusAfterRemoval method onCreate.

protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.focus_after_removal);
    final LinearLayout left = (LinearLayout) findViewById(R.id.leftLayout);
    // top left makes parent layout GONE
    Button topLeftButton = (Button) findViewById(R.id.topLeftButton);
    topLeftButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            left.setVisibility(View.GONE);
        }
    });
    // bottom left makes parent layout INVISIBLE
    // top left makes parent layout GONE
    Button bottomLeftButton = (Button) findViewById(R.id.bottomLeftButton);
    bottomLeftButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            left.setVisibility(View.INVISIBLE);
        }
    });
    // top right button makes top right button GONE
    final Button topRightButton = (Button) findViewById(R.id.topRightButton);
    topRightButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            topRightButton.setVisibility(View.GONE);
        }
    });
    // bottom right button makes bottom right button INVISIBLE
    final Button bottomRightButton = (Button) findViewById(R.id.bottomRightButton);
    bottomRightButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            bottomRightButton.setVisibility(View.INVISIBLE);
        }
    });
}
Also used : Button(android.widget.Button) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 38 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class HorizontalFocusSearch method makeTall.

private Button makeTall(String label) {
    Button button = new MyButton(this);
    button.setText(label);
    button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    return button;
}
Also used : Button(android.widget.Button) LinearLayout(android.widget.LinearLayout)

Example 39 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class HorizontalFocusSearch method addShort.

private Button addShort(LinearLayout root, String label, boolean atBottom) {
    Button button = new MyButton(this);
    button.setText(label);
    button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, // height
    0, 490));
    TextView filler = new TextView(this);
    filler.setText("filler");
    filler.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, // height
    0, 510));
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (atBottom) {
        ll.addView(filler);
        ll.addView(button);
        root.addView(ll);
    } else {
        ll.addView(button);
        ll.addView(filler);
        root.addView(ll);
    }
    return button;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 40 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class ListOfButtonsTest method TODO_testNavigateThroughAllButtonsAndBack.

// TODO: this reproduces bug 981791
public void TODO_testNavigateThroughAllButtonsAndBack() {
    String[] labels = getActivity().getLabels();
    for (int i = 0; i < labels.length; i++) {
        String label = labels[i];
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        getInstrumentation().waitForIdleSync();
        String indexInfo = "index: " + i + ", label: " + label;
        assertTrue(indexInfo, mListView.hasFocus());
        Button button = (Button) mListView.getSelectedView();
        assertNotNull(indexInfo, button);
        assertEquals(indexInfo, label, button.getText().toString());
        assertTrue(indexInfo, button.hasFocus());
    }
    // pressing down again shouldn't matter; make sure last item keeps focus
    sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
    for (int i = labels.length - 1; i >= 0; i--) {
        String label = labels[i];
        String indexInfo = "index: " + i + ", label: " + label;
        assertTrue(indexInfo, mListView.hasFocus());
        Button button = (Button) mListView.getSelectedView();
        assertNotNull(indexInfo, button);
        assertEquals(indexInfo, label, button.getText().toString());
        assertTrue(indexInfo, button.hasFocus());
        sendKeys(KeyEvent.KEYCODE_DPAD_UP);
        getInstrumentation().waitForIdleSync();
    }
    assertTrue("button at top should have focus back", mButtonAtTop.hasFocus());
    assertFalse(mListView.hasFocus());
}
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