黑莓 Editfield 将光标保持在右侧
我想创建一个编辑字段,其光标保持在其右侧。
为了说明如果我想写“黑莓”,结果应该是这样的。
<-----------width-of-editfield------>
b
bl
bla
blac
black
blackb
blackbe
blackber
blackberr
blackberry
谢谢
由于缺乏声誉的无意义的事情,我无法回答我自己的问题。
无论如何,我找到了一个简单的方法。 width
指的是保存该编辑字段的管理器的宽度。
editField = new EditField("","",maxChars,EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE){
protected boolean keyChar(char key, int status, int time) {
editField.setPadding(0, 0, 0, width - (getFont().getAdvance(this.getText())) - 10);
invalidate();
return super.keyChar(key, status, time);
}
};
I want to create an editfield whose cursor keeps at righthandside of it.
To illustrate if i want to write "blackberry", result should be like this.
<-----------width-of-editfield------>
b
bl
bla
blac
black
blackb
blackbe
blackber
blackberr
blackberry
Thanks
Because of non-sense of lack of reputation thing, i can not answer my own question.
Any way, I found an easy way. width
refers to width of the manager which holds this edit field.
editField = new EditField("","",maxChars,EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE){
protected boolean keyChar(char key, int status, int time) {
editField.setPadding(0, 0, 0, width - (getFont().getAdvance(this.getText())) - 10);
invalidate();
return super.keyChar(key, status, time);
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,您必须创建自己的
Manager
。没有简单或明显的方法可以做到这一点。A带有源代码的解决方案已发布在 BlackBerry 论坛上。
You will have to create your own
Manager
, unfortunately. There is no simple or obvious way to do this.A solution with source code was posted on the BlackBerry forums.
就像斯瓦蒂的解决方案一样。我确实是这样的:
Just like Swati's solution. I did like this: