您的位置:首页 > 移动开发 > Android开发

android EditText 去掉焦点和关闭软键盘

2012-07-04 15:34 274 查看
关闭软键盘 private void hideInputSoft() {

  try {

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

   imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);

  } catch (Exception e) {

   e.printStackTrace();

  }

 }

 private void hideInputSoft() {

  try {

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

   imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);

  } catch (Exception e) {

   e.printStackTrace();

  }

 } private void hideInputSoft() {

  try {

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

   imm.hideSoftInputFromWindow(mContext.getWindow().getDecorView().getWindowToken(), 0);

  } catch (Exception e) {

   e.printStackTrace();

  }

 }

 mDigits.setInputType(android.text.InputType.TYPE_NULL);//关闭软键盘

            android:focusable="true"

            android:focusableInTouchMode="true"//这个两个属性决定了编辑框的焦点去掉

 <LinearLayout

            android:id="@+id/contacts_input"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:orientation="horizontal"

            android:visibility="invisible" 

            android:background="@drawable/dialbk"

            android:focusable="true"

            android:focusableInTouchMode="true"

            >

            <ImageButton

                android:id="@+id/saveButton"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_gravity="center"

                android:background="@drawable/btn_dial_save_xml"

                android:contentDescription="@string/description_delete_button"

                android:state_enabled="false" 

                android:layout_marginLeft="6dip"

                android:layout_marginRight="6dip"

                />

            <EditText

                android:id="@+id/digits"

                android:layout_width="0dip"

                android:layout_height="wrap_content"

                android:layout_gravity="right|center"

                android:layout_weight="1"

                android:background="@drawable/dial_input_text_bg_xml"

                android:contentDescription="@string/description_digits_edittext"

                android:drawableLeft="@drawable/ic_calllog_call_active"

                android:minWidth="140.0dip"

                android:paddingLeft="13.0dip"

                android:paddingRight="4.0dip"

                android:scrollHorizontally="true"

                android:drawablePadding="7dip"

                android:singleLine="true"

                android:textColor="@color/white"

                android:textSize="22sp" 

                />

            <!-- </LinearLayout> -->

            <ImageView

                android:id="@+id/deleteButton"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_gravity="center"

                android:background="@drawable/btn_dial_delete_xml"

                android:contentDescription="@string/description_delete_button"

                android:scaleType="centerCrop"

                android:state_enabled="false" 

                 android:layout_marginLeft="6dip"

                android:layout_marginRight="6dip"/>

        </LinearLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息