/** @param view */ public static void showSoftKeyboard(final View view) { if (view == null) { return; } final Runnable action = new Runnable() { @Override public void run() { final InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); } }; final View.OnFocusChangeListener restoreOnFocusChangeListener = view.getOnFocusChangeListener(); final View.OnFocusChangeListener temporaryOnFocusChangeListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(final View v, final boolean hasFocus) { view.setOnFocusChangeListener(restoreOnFocusChangeListener); view.postDelayed(action, 25); } }; view.setOnFocusChangeListener(temporaryOnFocusChangeListener); view.requestFocus(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); View view = new Banner(this); view.setOnClickListener(this); setContentView(view); Log.d(TAG_NAME, "Banner View activated successfully!"); }
/** @param view */ public static void hideSoftKeyboard(final View view) { if (view == null) { return; } final Runnable action = new Runnable() { @Override public void run() { final InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow( view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); } }; view.postDelayed(action, 25); }
@Override public void onClick(View v) { v.setOnClickListener(null); Log.d(TAG_NAME, "View: " + v.toString() + " clicked!"); startActivity(new Intent(this, TocListActivity.class)); }