gpt4 book ai didi

java - 黑莓LableField 的 onClickListener 问题

转载 作者:行者123 更新时间:2023-12-02 00:16:52 24 4
gpt4 key购买 nike

我正在开发一个应用程序,其中我需要调用特定的电话号码,因为我已采用LableField并制作Number.setChangeListener(this); 并实现其方法 fieldChanged 并尝试处理事件,但我无法使用此 lablefield

这是代码::

import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.PhoneArguments;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class AboutM1 extends MainScreen implements FieldChangeListener {

VerticalFieldManager TOPVFM , DescriptionVFM,BottomVFM;
HorizontalFieldManager TOPHFM,CallHFM,EmailHFM,VIsitUsHFM ;

LabelField toplable,Description,Description2,Number,callus,Email,EmailID,Visitus,VisitLink;

Bitmap logom1;
BitmapField imgField;

public AboutM1() {

((VerticalFieldManager) getMainManager())
.setBackground(BackgroundFactory
.createSolidBackground(0xEDEDED));

TOPVFM = new VerticalFieldManager(USE_ALL_WIDTH);
TOPHFM = new HorizontalFieldManager(
FIELD_HCENTER | FIELD_VCENTER);


AllBITMAPDeclaration();

toplable = new LabelField("\n Welcome to", FIELD_BOTTOM) {
public void paint(Graphics g) {
g.setBackgroundColor(0xECECEC);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.RED);

g.clear();
super.paint(g);
}
};

FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 20);
font = fontFamily[1].getFont(Font.BOLD, 25);
toplable.setFont(font);


imgField = new BitmapField(logom1, FIELD_BOTTOM);

TOPHFM.add(toplable);
TOPHFM.add(imgField);

TOPVFM.add(TOPHFM);


add(TOPVFM);
LabelField Greenline = new LabelField(
"_______________________________________") {
protected void paint(Graphics g) {
g.setColor(0x324F85);
super.paint(g);
}

};

add(Greenline);

DescriptionVFM = new VerticalFieldManager(
VERTICAL_SCROLL);
Description = new LabelField(
"\nasdasdasd as da sd asd a sd reert er ter t e",
USE_ALL_WIDTH);
Description2 = new LabelField(
"\n\n About Us \n For customer care \n\n");
/*
* add(Description); add(Description2);
*/

DescriptionVFM.add(Description);
DescriptionVFM.add(new NullField(NullField.FOCUSABLE));
DescriptionVFM.add(Description2);


/******************************Bottom Area******************************************/

BottomVFM = new VerticalFieldManager(USE_ALL_WIDTH );
CallHFM = new HorizontalFieldManager(
FIELD_VCENTER);
callus = new LabelField("Call: ", FIELD_VCENTER);
Number = new LabelField("+91-79-30487400", FIELD_VCENTER) {


protected void paint(Graphics g) {
g.setColor(0x324F85);

// g.fillRoundRect(0, 0, 50, 5, 7, 7);
super.paint(g);
}

};
font = fontFamily[2].getFont(Font.BOLD, 18);
Number.setFont(font);

CallHFM.add(callus);
CallHFM.add(Number);
Number.setChangeListener(this);

EmailHFM = new HorizontalFieldManager(FIELD_VCENTER);
Email = new LabelField("Email: ", FIELD_VCENTER);
EmailID = new LabelField("Customasdercare@m1asdshopping.com", FIELD_VCENTER) {
protected void paint(Graphics g) {
g.setColor(0x324F85);
super.paint(g);
}
};

EmailID.setFont(font);
EmailID.setChangeListener(this);
EmailHFM.add(Email);
EmailHFM.add(EmailID);

VIsitUsHFM = new HorizontalFieldManager(FIELD_VCENTER);
Visitus = new LabelField("Visit us at: ", FIELD_VCENTER);
VisitLink = new LabelField("www.asdasd.com", FIELD_VCENTER) {
protected void paint(Graphics g) {
g.setColor(0x324F85);
super.paint(g);
}
};

VisitLink.setFont(font);
VisitLink.setChangeListener(this);
VIsitUsHFM.add(Visitus);
VIsitUsHFM.add(VisitLink);


BottomVFM.add(CallHFM);
BottomVFM.add(EmailHFM);
BottomVFM.add(VIsitUsHFM);

// add(BottomVFM);
DescriptionVFM.add(BottomVFM);


/********************************* END BOTTOM ************************************************/
add(DescriptionVFM);

}

private void AllBITMAPDeclaration() {
// TODO Auto-generated method stub
logom1 = Bitmap.getBitmapResource("logo36X36.png");
}

public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub
if(field == Number )
{
Dialog.alert("asdasd");
/* PhoneArguments arguments = new PhoneArguments(PhoneArguments.ARG_CALL, "180065449877");
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, arguments);*/
}
if(field == EmailID)
{
Dialog.alert("asdasd");
}
if(field == VisitLink)
{
Dialog.alert("asdasd");

}

}
}

最佳答案

试试这个 -

        LabelField  Number = new LabelField("+91-79-30345487400a5675675676", FIELD_VCENTER|Field.FOCUSABLE) {
protected void paint(Graphics g) {
g.setColor(0x324F85);

// g.fillRoundRect(0, 0, 50, 5, 7, 7);
super.paint(g);
}
protected boolean navigationClick(int status, int time) {
Dialog.alert("clicked");
return super.navigationClick(status, time);
}


};
add(Number);

关于java - 黑莓LableField 的 onClickListener 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11755087/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com