bb方法是在您想更改现有字段的样式(例如颜色)时扩展它们,因此下面是我的解决方案:
myauto.java:
package mypackage;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.decor.*;
import net.rim.device.api.system.*;
import net.rim.device.api.collection.util.*;
public class MyAuto extends UiApplication {
public static void main(String[] args) {
MyAuto myAuto = new MyAuto();
myAuto.enterEventDispatcher();
}
public MyAuto () {
pushScreen(new MyScreen());
}
}
class MyScreen extends MainScreen {
public MyScreen() {
BasicFilteredList filterList = new BasicFilteredList();
String[] days = {"Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday","Sunday"};
filterList.addDataSet(1,days,"days",BasicFilteredList.COMPARISON_IGNORE_CASE);
Background myBG = BackgroundFactory.createSolidBackground(Color.YELLOW);
Border myBorder = BorderFactory.createBitmapBorder(
new XYEdges( 20, 16, 27, 23 ),
Bitmap.getBitmapResource( "bubble_left.png" ) );
AutoCompleteField autoCompleteField = new AutoCompleteField(filterList);
autoCompleteField.setBorder(myBorder);
autoCompleteField.getEditField().setBackground(myBG);
add(autoCompleteField);
}
}
这个
bubble_left.png
不是真的需要,我只是为了好玩才添加的:
顺便说一下,在我的模拟器(bb 9800)的背景是白色的默认。