效果图:
[(
1)]
源码地址(github)
最近开发项目需要自定义收银键盘,网上查了查都感觉不是太好,于是自己写了一个,自定义的键盘主要是根据GridView+EditText结合来写的.
1.GridView如下:
android:inputType="numberDecimal"
android:editable="false"
android:layout_width="match_parent"
android:layout_height="0dp"
android:numColumns="4"
android:layout_weight="1"
android:id="@+id/gridview">
2.然后自己写了一个PayKeyAdapter,设置了键盘的文字和类型。
package com.example.qzs.keyboard_cash;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class PayKeyAdapter extends BaseAdapter {
private Context mContext;
private Context context;
public PayKeyAdapter(Context context) {
this.context=context;
}
private String[] texts = {
//九宫格图片下方文字的设置
"1",
"2",
"3",
"清空",
"4",
"5",
"6",
"←",
"7",
"8",
"9",
"=",
".",
"0",
"+",
"收款",
};
private String[] types = {
//存放在text的tag中
"num",
"num",
"num",
"cancel",
"num",
"num",
"num",
"back",
"num",
"num",
"num",
"equal",
"point",
"num",
"plus",
<