我有一个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;
}
答案 0 :(得分:0)
尝试像这样使用
android:inputType="numberDecimal"