Button myBtn = (Button)findViewById(R.id.myButtonId); myBtn.requestFocus();
Button mybtn2 = (Button) focusSearch(View.FOCUS_DOWN); if (mybtn2 != null) mybtn2.requestFocus();
Button quick_start = (Button) findViewById(R.id.start); quick_start.setSelected(true); quick_start.requestFocus();
public void paint(Graphics g) { super.paint(g); if (firstPaint) { yesB.requestFocus(); firstPaint = false; } }
public void paint(Graphics g) { super.paint(g); if (firstPaint) { yesB.requestFocus(); firstPaint = false; } } }
public void paint(Graphics g) { super.paint(g); if (firstPaint) { yesB.requestFocus(); firstPaint = false; } }
final ScrollView s = (ScrollView)findViewById(R.id.ScrollView01); s.post(new Runnable() { public void run() { EditText editText =(EditText) findViewById(R.id.yourEditText); (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(editText.getWindowToken(), 0); Button button =(Button) findViewById(R.id.SaveProfileEditingButton); button.setFocusable(true); button.requestFocus(); } });
alertDialog.setOnShowListener(new DialogInterface.OnShowListener(){ @Override public void onShow(DialogInterface dialog) { Button negative = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); negative.setFocusable(true); negative.setFocusableInTouchMode(true); negative.requestFocus(); } }); alertDialog.show();
// Set the focus to the calculate button so the keyboard won't show up automatically Button calcButton = (Button)findViewById( R.id.ac_button_calculate ); calcButton.setFocusable( true ); calcButton.setFocusableInTouchMode( true ); calcButton.requestFocus();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener(){ @Override public void onShow(DialogInterface dialog) { Button positive= alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); positive.setFocusable(true); positive.setFocusableInTouchMode(true); positive.requestFocus(); } });
TextView v = ...; final Button b = ...; v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { b.setFocusableInTouchMode(true); b.requestFocus(); b.performClick(); } });
btn_map.setOnClickListener(new OnClickListener() { public void onClick(View v) { btn_map.requestFocus(); btn_map.setFocusable(true); SharedPreferences.Editor prefsEditor = prefs.edit(); btn_name.setOnClickListener(new OnClickListener() { public void onClick(View v) { btn_name.requestFocus(); btn_name.setFocusable(true); SharedPreferences.Editor prefsEditor = prefs.edit();
public void actionPerformed(ActionEvent e) { logout(); loginButton.setEnabled(true); logoutButton.setEnabled(false); loginButton.requestFocus(); } });
loginButton.requestFocus(); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
public ShutdownDialog(final ViewerFrame owner) { super(owner, "Naked Objects", true); //AWTUtilities.addWindowIcon(this, "shutdown-logo.gif"); setLayout(new GridLayout(2, 3, 10, 10)); add(new Label("Exit Naked Objects?", Label.LEFT)); add(new Panel()); add(new Panel()); add(new Panel()); add(quit = new Button(QUIT_LABEL)); quit.addActionListener(this); quit.addKeyListener(this); add(cancel = new Button(CANCEL_LABEL)); cancel.addActionListener(this); cancel.addKeyListener(this); pack(); int width = getSize().width; // getWidth(); int height = getSize().height; // getHeight(); Dimension screen = owner.getSize(); Point point = owner.getLocation(); int x = point.x + (screen.width / 2) - (width / 2); int y = point.y + (screen.height / 2) - (height / 2); setLocation(x, y); show(); quit.requestFocus(); addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent e) { dispose(); } }); }