簡體   English   中英

單擊時不會彈出Android EditText數字鍵盤

[英]Android EditText number keyboard not popping up upon click

我有一個ListView,它來自我創建的自定義行。 一切正常,接受我的EditText拒絕顯示數字鍵盤的事實。

以下是我的XML:

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

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:id="@+id/chkPlayer" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/txtName"
        android:layout_toRightOf="@+id/chkPlayer"
        android:layout_alignBottom="@+id/chkPlayer"/>

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/started"
        android:layout_below="@+id/txtName"
        android:layout_marginLeft="26dp"
        android:id="@+id/chkStarted" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/captain"
        android:layout_below="@+id/txtName"
        android:layout_toRightOf="@+id/chkStarted"
        android:id="@+id/chkCaptain" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/gk"
        android:layout_below="@+id/txtName"
        android:layout_toRightOf="@+id/chkCaptain"
        android:id="@+id/chkGK" />

    <EditText
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:ems="10"
        android:id="@+id/txtTime"
        android:layout_marginLeft="@dimen/margin10"
        android:hint="@string/time"
        android:layout_alignBottom="@+id/chkGK"
        android:layout_toRightOf="@+id/chkGK" />
</RelativeLayout>

我嘗試了幾種其他方法,但是根本無法使其正常工作,下面是我的自定義陣列適配器:

@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
    View rowView = convertView;

    if(rowView == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.row_squad, parent, false);

        holder = new Holder();
        holder.txtName = (TextView)rowView.findViewById(R.id.txtName);
        holder.chkPlayer = (CheckBox)rowView.findViewById(R.id.chkPlayer);
        holder.txtTime = (EditText)rowView.findViewById(R.id.txtTime);

        rowView.setTag(holder);
    }
    else {
        holder = (Holder) convertView.getTag();
    }

    holder.txtName.setText(playerNames.get(position));
    holder.chkPlayer.setFocusable(false);
    holder.chkStarted.setFocusable(false);
    holder.chkCaptain.setFocusable(false);
    holder.chkGK.setFocusable(false);
    //holder.txtTime.setFocusable(true);
    //InputMethodManager im = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    //im.showSoftInput(holder.txtTime, InputMethodManager.SHOW_IMPLICIT));
    //EditText txtTime = (EditText)rowView.findViewById(R.id.txtTime);

    return rowView;
}

嘗試像這樣使用

android:inputType="numberDecimal"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM