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;
}
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);
}
});
}
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;
}
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;
}
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());
}
Aggregations