2010-08-07 5 views
1

Blackberry에서 URL 링크를 만드는 방법에 대해 누구나 말해 줄 수 있나요? 클릭 한 후에 웹 페이지를 여는 방법이 있습니까?Blackberry 프로그램에서 URL을 만드는 방법

+3

무슨 짓을 너 시도해? 너는 무엇에 문제가 있니? – Oded

+0

나는 검은 딸기에 새로운이고 URL 링크를 표시하기위한 코드를 찾고 있는데, 클릭 한 후에 웹 페이지를 열어야한다 .. 어떤 코드를 시도했지만 작동하지 않는다 ... – user413715

+1

다시 : 어떤 코드 시도해 보았습니까? 정확히 어떻게 실패 했습니까? –

답변

1
// This can eb a nested class in your screen class. 
class URLButtonField extends ButtonField { 
    String url; 
    public URLButtonField(String label, String url) { 
     super(label); 
     this.url = url; 
    } 
    public String getURL() { 
     return url; 
    } 
    public void setURL(String url) { 
     this.url = url; 
    } 
}  



// member variable of your screen class- this will let you access it later 
// to change the URL 
URLButtonField bf; 

// In your screen's constructor: 

bf = new ButtonField("Example", "http://www.example.com"); 
bf.setFieldChangeListener(new FieldChangeListener() { 
    void fieldChanged(Field field, int context) { 
     if (field == this) { 
      BrowserSession session =- Browser.getDefaultSession(); 
      session.displayPage(getURL()); 
     } 
    } 
});   
add(bf); 
그런 다음 언제든지 "BF"의 텍스트 또는 대상 URL을 변경할 수 있으며, 무엇을 당신이 될 것입니다 그것을 클릭하면 시작되는 URL을 변경

:

// In response to some activity: 
bf.setText("Example Two"); 
bf.setURL("http://www.example.com/two"); 
관련 문제