01-20-2013 12:53 AM
CAN ANYONE HELP ME CREATE A LINK WHERE USERS CLICK ON IT AND THEN SENDS THEM TO ANOTHER WEB SITE OR A NEW SCREEN JUST AS IN ( <a href ="google.com">continue</a> )
Solved! Go to Solution.
01-20-2013 05:21 AM - edited 01-21-2013 04:38 AM
Just to confirm, you want to do this and display the short form on the BBOS device and have the user click on that and it will take them to the other web site. I presume also this will be included along with other 'text'.
ActiveTextFields will do that but you have to put the full URL in them.
The only way to get the abbreviated text displayed for is to add a BrowserField. I would not recommend doing that unless you intended to use a BrowserField for the whole screen.
You can create other hot links in ActiveTextFields using the pattern matching, see here:
01-21-2013 03:39 AM
you can use
HyperlinkButtonField in the third party API
exp:
HyperlinkButtonField testHyperLink=
new HyperlinkButtonField("test txt", 0x0000FF, 0xFFFFFF, 0x0000FF, 0,
0, FIELD_HCENTER);
testHyperLink.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
//do logic
Browser.getDefaultSession().displayPage(url);
}
});
notes : url must be full path ![]()
01-21-2013 06:27 AM
How so I reference the third party api ?
01-21-2013 06:45 AM
01-21-2013 10:24 AM
/*
* HyperlinkButtonField.java
*/
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.LabelField;
public class HyperlinkButtonField extends LabelField {
// text color
private int textColour;
// text focus color
private int textColourFocus;
// highlight color
private int highlightColour;
private int menuOrdinal;
private int menuPriority;
private XYRect tmpRect = new XYRect();
public HyperlinkButtonField(String text, int textColour,
int highlightColour, int menuOrdinal, int menuPriority) {
this(text, textColour, textColour, highlightColour, menuOrdinal,
menuPriority);
}
public HyperlinkButtonField(String text, int textColour,
int textColourFocus, int highlightColour, int menuOrdinal,
int menuPriority) {
this(text, textColour, textColourFocus, highlightColour, menuOrdinal,
menuPriority, 0);
}
public HyperlinkButtonField(String text, int textColour,
int textColourFocus, int highlightColour, int menuOrdinal,
int menuPriority, long style) {
super(text, Field.FOCUSABLE | style);
this.textColour = textColour;
this.textColourFocus = textColourFocus;
this.highlightColour = highlightColour;
this.menuOrdinal = menuOrdinal;
this.menuPriority = menuPriority;
}
public HyperlinkButtonField(String text, int textColour,
int textColourFocus, int highlightColour, long style) {
super(text, Field.FOCUSABLE | style);
this.textColour = textColour;
this.textColourFocus = textColourFocus;
this.highlightColour = highlightColour;
this.menuOrdinal = 0;
this.menuPriority = 0;
}
public HyperlinkButtonField(String text, int textColour,
int textColourFocus, int highlightColour) {
super(text, Field.FOCUSABLE);
this.textColour = textColour;
this.textColourFocus = textColourFocus;
this.highlightColour = highlightColour;
this.menuOrdinal = 0;
this.menuPriority = 0;
}
public void applyFont() {
Font underlineFont = getFont().derive(Font.UNDERLINED);
setFont(underlineFont);
}
protected void paint(Graphics g) {
int oldColour = g.getColor();
try {
if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
g.setColor(textColourFocus);
} else {
g.setColor(textColour);
}
super.paint(g);
} finally {
g.setColor(oldColour);
}
}
protected void drawFocus(Graphics g, boolean on) {
getFocusRect(tmpRect);
boolean oldDrawStyleFocus = g
.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS);
int oldBackgroundColour = g.getBackgroundColor();
boolean notEmpty = g.pushContext(tmpRect.x, tmpRect.y, tmpRect.width,
tmpRect.height, 0, 0);
try {
if (notEmpty) {
if (on) {
g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true);
g.setBackgroundColor(highlightColour);
}
g.clear();
paint(g);
}
} finally {
g.popContext();
g.setBackgroundColor(oldBackgroundColour);
g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, oldDrawStyleFocus);
}
}
protected boolean keyChar(char character, int status, int time) {
if (character == Characters.ENTER) {
fieldChangeNotify(0);
return true;
}
return super.keyChar(character, status, time);
}
protected boolean trackwheelClick(int status, int time) {
keyChar(Characters.ENTER, status, time);
return true;
}
protected boolean invokeAction(int action) {
switch (action) {
case ACTION_INVOKE: {
fieldChangeNotify(0);
return true;
}
}
return super.invokeAction(action);
}
public void setDirty(boolean dirty) {
// We never want to be dirty or muddy
}
public void setMuddy(boolean muddy) {
// We never want to be dirty or muddy
}
public String getMenuText() {
return getText();
}
/**
* Returns a MenuItem that could be used to invoke this link.
*/
public MenuItem getMenuItem() {
if (menuOrdinal < 0 || menuPriority < 0) {
return null;
}
return new MenuItem(getMenuText(), menuOrdinal, menuPriority) {
public void run() {
fieldChangeNotify(0);
}
};
}
} enjoy it .. and u can find third party resource if u search here
it's rich GUI
01-21-2013 10:30 AM