[size=1em]1 | [size=1em][size=1em]InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); |
[size=1em]1 [size=1em]2 [size=1em]3 [size=1em]4 [size=1em]5 [size=1em]6 [size=1em]7 [size=1em]8 [size=1em]9 [size=1em]10 [size=1em]11 [size=1em]12 [size=1em]13 [size=1em]14 [size=1em]15 [size=1em]16 [size=1em]17 [size=1em]18 [size=1em]19 [size=1em]20 [size=1em]21 [size=1em]22 [size=1em]23 [size=1em]24 [size=1em]25 [size=1em]26 [size=1em]27 [size=1em]28 [size=1em]29 [size=1em]30 [size=1em]31 [size=1em]32 | [size=1em][size=1em]package token.token; [size=1em]import android.app.Activity; [size=1em]import android.content.Context; [size=1em]import android.os.Bundle; [size=1em]import android.os.IBinder; [size=1em]import android.view.View; [size=1em]import android.view.ViewGroup; [size=1em]import android.view.inputmethod.InputMethodManager; [size=1em]import android.widget.Button; [size=1em]import android.widget.EditText; [size=1em]public class TokenActivity extends Activity { [size=1em] /** Called when the activity is first created. */ [size=1em] EditText et = null; [size=1em] InputMethodManager imm = null; [size=1em] IBinder ib = null; [size=1em] Button bt = null; [size=1em] @Override [size=1em] public void onCreate(Bundle savedInstanceState) { [size=1em] super.onCreate(savedInstanceState); [size=1em] setContentView(R.layout.main); [size=1em] et = (EditText)findViewById(R.id.edit); [size=1em] bt = (Button)findViewById(R.id.button); [size=1em] [size=1em] imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); [size=1em] } [size=1em] public void aa(View v){ [size=1em] <span style="color:#e53333;">et.requestFocus();</span> // imm.showSoftInput(et, imm.SHOW_FORCED);//chenggong [size=1em] <span style="color:#e53333;">imm.showSoftInput(et, 0);</span> // imm.hideSoftInputFromWindow(bt.getWindowToken(), 0); [size=1em] } [size=1em]} |
[size=1em]1 [size=1em]2 [size=1em]3 [size=1em]4 [size=1em]5 | [size=1em][size=1em]public void aa(View v){ [size=1em] ib = et.getWindowToken(); [size=1em] imm.showSoftInput(bt, 0); [size=1em] imm.hideSoftInputFromWindow(bt.getWindowToken(), 0); [size=1em] } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |