I want to bold specific letters in my EditField.
public void changeToBold() {
try {
alphaSans = FontFamily.forName("BBAlpha Sans");
font = alphaSans.getFont(Font.BOLD, 9, Ui.UNITS_pt);
editField.setFont(font);
} catch (ClassNotFoundException e) {
Dialog.alert("alert");
}
}
public void changeToPlain() {
try {
alphaSans = FontFamily.forName("BBAlpha Sans");
font = alphaSans.getFont(Font.PLAIN, 9, Ui.UNITS_pt);
editField.setFont(font);
} catch (ClassNotFoundException e) {
Dialog.alert("alert");
}
}开发者_高级运维
I add the text to the EditField from a sqlite db.
while(c1.next() && c2.next()) {
r1 = c1.getRow();
r2 = c2.getRow();
temp = r2.getString(0);
changeToBold();
theText += temp;
changeToPlain();
theText += r.1getString(0);
}
*Maybe there is a way to create a LabelField that holds the text I wnat in bold and then add it simultaneously to the EditField?
You need to use RichTextField. See How To - Format text in a RichTextField for an example.
精彩评论