久久久久久久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問題)
主站蜘蛛池模板: 美女日皮网站 | 一区二区三区av | 黄色一级电影免费观看 | 国产精品久久久久久久久图文区 | 91九色在线观看 | 国产成人免费视频网站视频社区 | 精品一区国产 | 97超碰在线免费 | 国产欧美在线 | 亚洲精品永久免费 | 精品一二区 | 欧美日韩在线不卡 | 久久久夜夜夜 | 欧美一区二区在线播放 | 99精品欧美一区二区三区 | 久久成人免费视频 | 亚洲欧美综合 | 久久丝袜 | 亚洲免费视频网站 | 久久精品国产一区二区三区不卡 | 日本免费网 | 黑人巨大精品欧美一区二区免费 | 中文精品一区二区 | jvid精品资源在线观看 | 黄色网址免费在线观看 | 视频在线一区二区 | 欧美成人一区二区三区 | 欧美视频 亚洲视频 | 青青草视频免费观看 | 久久99视频 | 91精品国产欧美一区二区 | 国产成人在线一区二区 | 伊人久久大香线 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 中文在线观看视频 | 日韩中文字幕在线观看 | 中文字幕影院 | 久久久久国产一区二区 | 波霸ol一区二区 | 国内精品视频在线观看 | 特黄视频 |