久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 NumberPicker 上禁用軟鍵盤

Disable soft keyboard on NumberPicker(在 NumberPicker 上禁用軟鍵盤)
本文介紹了在 NumberPicker 上禁用軟鍵盤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我試圖在使用 NumberPicker 輸入數值時停用軟鍵盤(出于美觀原因).這是我的布局 XML 代碼:

I'm trying to deactivate the soft keyboard when using a NumberPicker to enter numerical values (for aesthetic reasons). This is my layout-xml-code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp" >

        <NumberPicker
            android:id="@+id/repetitionPicker"
            android:layout_width="40dp"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="@string/repetitions_short_divider"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <NumberPicker
            android:id="@+id/weightPicker"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="@string/pounds"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </LinearLayout>


    <Button
        android:id="@+id/saveButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/save" />

</LinearLayout>

最后,這是我嘗試在 onCreate() 方法中阻止鍵盤的代碼:

And finally this is the code where I try to block the keyboard in the onCreate()-method:

// hide keyboard
View.OnClickListener disableKeyBoardListener = new View.OnClickListener() {
    public void onClick(View v) {
        ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
};

((EditText) weightPicker.getChildAt(1)).setInputType(InputType.TYPE_NULL);
((EditText) repetitionPicker.getChildAt(1)).setInputType(InputType.TYPE_NULL);

((EditText) weightPicker.getChildAt(1)).setOnClickListener(disableKeyBoardListener);
//((EditText) repetitionPicker.getChildAt(1)).setOnClickListener(disableKeyBoardListener);
//weightPicker.setOnClickListener(disableKeyBoardListener);
//repetitionPicker.setOnClickListener(disableKeyBoardListener);     

getWindow().setSoftInputMode(
        WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

遺憾的是,點擊 NumberPicker 時仍會顯示軟鍵盤.有什么想法嗎?

Sadly, the soft keyboard still shows up when clicking on a NumberPicker. Any ideas?

推薦答案

剛找到這個,它就像一個魅力:

Just found this and it works like a charm:

myNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

您也可以在 XML 中設置:

You can also set this in XML:

android:descendantFocusability="blocksDescendants" 

這篇關于在 NumberPicker 上禁用軟鍵盤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 亚洲h在线观看 | 久久久久久久久久久福利观看 | www.色.com | 大学生a级毛片免费视频 | 综合九九| 亚洲一区不卡 | 美女视频. | 日韩欧美中文 | 麻豆久久久9性大片 | 久久久久电影 | 日韩1区 | 国产精品揄拍一区二区 | 精品久久香蕉国产线看观看亚洲 | 一区二区三区四区免费观看 | 亚洲国产精品一区二区三区 | 精品一区国产 | 欧美综合久久 | 国产精品一区在线 | 欧美激情精品久久久久久免费 | 成人在线视| 日本三级日产三级国产三级 | 91福利影院 | 精品91久久 | 久久久久亚洲av毛片大全 | 国产av毛片| 精品一区二区在线观看 | 日韩欧美一区二区在线播放 | 亚洲免费在线视频 | 精品亚洲一区二区 | 日韩国产欧美 | 日韩欧美视频在线 | 亚洲不卡视频 | 一区二区三区网站 | 久久综合久久综合久久 | 亚洲国产高清高潮精品美女 | 91高清在线观看 | 国产免费xxx | av黄色国产 | 久久成人免费 | 欧美日韩综合 | 亚洲国产精品一区二区第一页 |