简体   繁体   中英

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. 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. And simply each button click would add the corresponding value to your EditText.

Addition

To clarify, a "phone" keyboard on an HTC:

HTC键盘

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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