0

我是 android 应用程序开发的新手,所以如果我的问题听起来很业余,我很抱歉。我试图在网上搜索我的问题的答案,但我认为我可能没有使用正确的术语,因为我想做的并不是什么新鲜事。请帮助我走上正确的道路。

我想创建一个应用程序,其中我的一个页面可以使用不同语言的键盘。该语言不能用英文字母表示,但在 Windows 等中有可用的字体,因此它是一种已知语言。我希望用户从键盘中选择字母并将字母打印到相同语言的文本框中。接下来,使用用户输入的字母,我想在数据库中搜索特定的字母字符串,并找到输入行所在的页码。

第 1 部分:我试图弄清楚在构建键盘时应该使用哪种方法。我想出的是,我需要创建一个图像按钮表,其中包含每个字符的图像。这是一个好方法还是有更好的方法来做到这一点?

第 2 部分:当用户从图像按钮表中选择一个字母时,如何以特定语言打印它?我确实在 res/values-pa 下为这种语言创建了一个 strings.xml(我查了一下,ISO 639-1 代码是“pa”)。我不知道该怎么做是当用户从键盘选择它时打印该语言的字符?

谢谢你。

4

2 回答 2

0

If you need to create a full featured keyboard, look up the InputMethodService and derive a class from it. The user can then select it as a keyboard. But if you just want to have them input text in their native language, all they need to do is select that as their locale and have a keyboard that supports that locale installed on the phone- it would be very unusual and probably wrong for you to be coding a keyboard. Not to mention a good keyboard takes a ton of work- the big Android keyboards have teams of programmers and linguists on them.

于 2013-03-14T20:55:03.053 回答
0

Firstly, you're going to need to include a font for that language in your app. There's a good tutorial on including and using them here.

After that, You could set the text of each of your buttons to one of the characters from that font.

Then in the onClick() of every button, do something like:

String letter = clickedButton.getText();
myEditText.setText(myEditText.getText() + letter);

Where clickedButton is the button that was clicked and myEditText is your EditText

于 2013-03-14T20:55:11.363 回答