Im making an app which has a listener on incoming calls and then adds fields til the phonescreen.. However i cannot seem to really control the width of either labelfields or the PhoneScreenVerticalManager i use. If i try to set a border or background on the PhoneScreenVerticalManager nothing happens at all. It also seems like USE_ALL_WIDTH in the labelfield constructor doesn t change anything. And getting the labelfields to left align i also couldn t get to work (tried DrawStyle.Left in the labelfield constructor).
我的守则是:
public Incoming(int callId) {
this.callId = callId;
PhoneCall call = Phone.getCall(callId);
String number = call.getPhoneNumber();
Vector contact = ContactUtil.getContactByPhone(number);
screenModel = new ScreenModel(callId);
phoneScreenPortrait = screenModel.getPhoneScreen(PhoneScreen.PORTRAIT, PhoneScreen.INCOMING);
final XYRect rect = screenModel.getDimensions(PhoneScreen.PORTRAIT, PhoneScreen.INCOMING);
PhoneScreenVerticalManager manager = new PhoneScreenVerticalManager()
{
public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
protected void sublayout(int width, int height)
{
super.sublayout(rect.width, height);
super.setExtent(rect.width, height);
}
};
manager.setBackground(BackgroundFactory.createSolidBackground(Color.RED));
manager.setBorder(BorderFactory.createSimpleBorder(new XYEdges(BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING), Border.STYLE_SOLID));
String s = res.getString(FOUND_IN_CONTACTS);
LabelField header = new LabelField(s, LabelField.USE_ALL_WIDTH)
{
protected void layout(int width, int height)
{
super.layout(rect.width, height);
setExtent(rect.width, height);
}
public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
};
header.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
manager.add(header);
LabelField label = new LabelField(contact.firstElement().toString(), LabelField.USE_ALL_WIDTH)
{
protected void layout(int width, int height)
{
super.layout(rect.width, height);
setExtent(rect.width, height);
}
public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.setBackgroundColor(Color.WHITE);
g.clear();
super.paint(g);
}
};
label.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
manager.add(label);
phoneScreenPortrait.add(manager);
screenModel.sendAllDataToScreen();
}
任何想法都会受到高度赞赏!
增 编