Android軟鍵盤用法實(shí)例

package com.example.key;

創(chuàng)新互聯(lián)主要從事網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)鳳臺(tái),10年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18980820575

import android.os.Bundle;

import android.app.Activity;

import android.content.Context;

import android.view.Menu;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.view.View.OnClickListener;

import android.view.inputmethod.InputMethodManager;

public class MainActivity extends Activity {

 @Override

 protected void onCreate(Bundle savedInstanceState) { 

   super.onCreate(savedInstanceState); 

   setContentView(R.layout.activity_main); 

   final EditText ed2 = (EditText) findViewById(R.id.editText1);

   Button b1 = (Button) findViewById(R.id.button1); 

   b1.setOnClickListener(new OnClickListener() { 

     @Override

     public void onClick(View v) { 

       ed2.requestFocus(); 

       show(ed2); 

     } 

   });

   Button b2 = (Button) findViewById(R.id.button2);

   b2.setOnClickListener(new OnClickListener() {

     @Override

     public void onClick(View v) {

       toggle();

     }

   });

 }

 private void show(EditText ed2) {

   InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

   imm.showSoftInput(ed2, InputMethodManager.SHOW_IMPLICIT);

 }

 private void toggle() {

   InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

   imm.toggleSoftInput(0, 0);

 }

 @Override

 public boolean onCreateOptionsMenu(Menu menu) {

   // Inflate the menu; this adds items to the action bar if it is present.

   getMenuInflater().inflate(R.menu.main, menu);

   return true;

 }

}

當(dāng)前題目:Android軟鍵盤用法實(shí)例
轉(zhuǎn)載來(lái)于:http://www.muchs.cn/article48/jdooep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、虛擬主機(jī)、動(dòng)態(tài)網(wǎng)站、標(biāo)簽優(yōu)化移動(dòng)網(wǎng)站建設(shè)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)