简体   繁体   English

用于计算器应用的定制键盘

[英]Customized keypad for a calculator application

I've seen lots and lots of questions about selecting the best input Type keypad for edit texts, yet I couldn't find the one that helps me out with a semi calculator app. 我已经看到很多关于为编辑文本选择最佳输入类型键盘的问题,但我找不到一个能帮助我使用半计算器应用程序的键盘。 I have tried decimal, phone, number flag signed and their combination but it doesn't give me what I am looking for. 我已经尝试过十进制,电话,数字标志签名和他们的组合,但它没有给我我想要的东西。

Is there any input type including numbers, (+), (-) and (.) ? 是否有任何输入类型,包括数字,(+),( - )和(。)? Or how can I create and use this keypad if I have to? 或者,如果必须,我该如何创建和使用此键盘?

Have you tried this, it seems to have what you want: 你试过这个,它似乎有你想要的东西:

<EditText
    ...
    android:inputType="number"
    />

Aside from numbers and basic operators, it includes the underscore. 除了数字和基本运算符,它还包括下划线。 It even has modulo (%), factorial (!), confusion (?) should you decide to get fancy... 它甚至有模数(%),阶乘(!),混乱(?),如果你决定想要...

Addition 加成

This is probably closer to what you want, since you apparently aren't looking for an underscore... 这可能更接近你想要的,因为你显然不是在寻找下划线......

<EditText
    ...
    android:inputType="phone"
    />

I only know of the three basic keyboards include in Android. 我只知道Android中的三个基本键盘。 If the "phone" keyboard isn't an acceptable option, you probably have to design your own... 如果“手机”键盘不是一个可接受的选项,你可能需要设计自己的...

The way I would approach designing a keyboard is like any other app. 我设计键盘的方式就像任何其他应用程序一样。 For this I would use an EditText above a TableLayout to help you organize your grid of buttons. 为此,我将使用TableLayout上方的EditText来帮助您组织按钮网格。 And simply each button click would add the corresponding value to your EditText. 只需单击每个按钮,就会将相应的值添加到EditText中。

Addition 加成

To clarify, a "phone" keyboard on an HTC: 为了澄清,HTC上的“手机”键盘:

HTC键盘

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM