android EditText 去掉焦點和關閉軟鍵盤

來源:互聯網
上載者:User

關閉軟鍵盤 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>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.