安卓開發中遇到問題的解決,網上搜索到的方法有一些問題,故而採用以下方法android
給activity佈局文件加入 idide
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 佈局
xmlns:tools="http://schemas.android.com/tools" spa
android:layout_width="fill_parent" xml
android:layout_height="fill_parent" 事件
android:scrollbars="vertical" 開發
android:id="@+id/activity_main" get
> it
按照通常控件的方式進行事件監聽。 io
activity_main=(LinearLayout) findViewById(R.id.activity_main);
activity_main.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View arg0, MotionEvent arg1)
{
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
});