2012-01-16 110 views
2

我需要在我的應用程序視圖中顯示一些鏈接。但我找不到任何關於它的事情。可能嗎??如何在我的視圖中使用黑莓瀏覽器hiearchy?

我想將瀏覽器內容(字段)放在操作系統的灰色區域< 5.00?

must be this image

+0

去這個鏈接:http://stackoverflow.com/questions/7606462/how-to-stop-browserfield-requestcontent-method-when-back-to-mainscreen-on- bla/7607061#7607061 將鏈接(url)作爲參數發送給該構造函數;並調用屏幕; – alishaik786 2012-01-16 10:42:04

+0

Browserfiled是inse BlackBerry API 5.0.0。我必須爲所有版本使用字段。也許我需要從字段擴展customBrowser? – atasoyh 2012-01-16 12:31:38

回答

0

如果你想顯示的字段,它是一個超鏈接使用下面的代碼。

package com.myApp.controls; 

import net.rim.device.api.ui.Color; 
import net.rim.device.api.ui.Field; 
import net.rim.device.api.ui.Font; 
import net.rim.device.api.ui.Graphics; 
public class HrefField extends Field { 

private String content; 
private Font fieldFont; 
private int fieldWidth; 
private int fieldHeight; 
private boolean active = false; 
private int backgroundColour = Color.WHITE; 
private int textColour = Color.BLACK; 
private int[] drawFocusColors; 

public HrefField(String content) { 
    super(Field.FOCUSABLE); 
    this.content = content; 
    fieldFont = Font.getDefaultFont(); 
    fieldWidth = fieldFont.getAdvance(content) + 2; 
    fieldHeight = fieldFont.getHeight() + 3; 
    drawFocusColors = new int[] { Color.ORANGE, 
      Color.ORANGE,Color.RED, 
      Color.RED}; 
} 

public void setColours(int backgroundColour, int textColour) { 
    this.backgroundColour = backgroundColour; 
    this.textColour = textColour; 
    invalidate(); 
} 

public void setBackgroundColour(int backgroundColour) { 
    this.backgroundColour = backgroundColour; 
    invalidate(); 
} 

public void setTextColour(int textColour) { 
    this.textColour = textColour; 
    invalidate(); 
} 

public void setMaskColour() { 
    invalidate(); 
} 

public void setFont(Font fieldFont) { 
    this.fieldFont = fieldFont; 
} 

public int getPreferredWidth() { 
    return fieldWidth; 
} 

public int getPreferredHeight() { 
    return fieldHeight; 
} 

protected void layout(int arg0, int arg1) { 
    setExtent(getPreferredWidth(), getPreferredHeight()); 
} 

protected void paint(Graphics graphics) { 
    int[] X_PTS = new int[] { 0, fieldWidth, fieldWidth, 0 }; 
    int[] Y_PTS = { 0, 0, fieldHeight, fieldHeight }; 
    if (active) { 
     graphics.drawShadedFilledPath(X_PTS, Y_PTS, null, drawFocusColors, 
       null); 
    } else { 
     graphics.setColor(backgroundColour); 
     graphics.fillRect(0, 0, fieldWidth, fieldHeight); 
    } 

    graphics.setColor(textColour); 
    graphics.setFont(fieldFont); 
    graphics.drawText(content, 1, 1); 
    graphics.drawLine(1, fieldHeight - 2, fieldWidth - 2, fieldHeight - 2); 
} 

protected boolean navigationClick(int status, int time) { 
    fieldChangeNotify(1); 
    return true; 
} 

protected void onFocus(int direction) { 
    active = true; 
    invalidate(); 
} 

protected void onUnfocus() { 
    active = false; 
    invalidate(); 
} 

}

+0

不,謝謝。我會打開一些網址。 – atasoyh 2012-01-16 12:19:59