2012-03-18 5 views
0

검은 딸기의 화면 하단에 4 개의 클릭 가능한 이미지/아이콘을 표시하고 싶습니다.이 샘플 응용 프로그램을 찾을 수 없습니다. 일부 미리보기를 공유하십시오.화면 하단에 이미지/아이콘 추가

내가 이것을 시도했지만 내가 맨 아래에있는 이미지를 표시하고 만들 수 아니다 그것을 클릭

package com.samples.backgroundImage; 

import net.rim.device.api.ui.*; 
import net.rim.device.api.ui.component.*; 
import net.rim.device.api.ui.container.*; 
import net.rim.device.api.system.*; 

public class NativeUI extends UiApplication 
{ 
    private Bitmap backgroundBitmap; 
    private Bitmap fieldBitmap; 

    public static void main(String[] args) 
    { 
      NativeUI theApp = new NativeUI(); 
      theApp.enterEventDispatcher(); 
    } 

    public NativeUI() 
    { 
     //The background image. 
     backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png"); 

     MainScreen mainScreen = new MainScreen(); 

     HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){ 

      //Override the paint method to draw the background image. 
      public void paint(Graphics graphics) 
      { 
       //Draw the background image and then call paint. 
       graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0); 
       super.paint(graphics); 
      }    

     }; 

     //The LabelField will show up through the transparent image. 
     LabelField labelField = new LabelField("This is a label"); 

     //A bitmap field with a transparent image. 
     //The background image will show up through the transparent BitMapField image. 
     BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png")); 

     //Add the manager to the screen. 
     mainScreen.add(horizontalFieldManager); 
     BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL); 
     horizontalFieldManager.add(bef); 
     //Add the fields to the manager. 
     horizontalFieldManager.add(labelField); 
     horizontalFieldManager.add(bitmapField); 

     //Push the screen. 
     pushScreen(mainScreen); 
    } 
} 
+0

확인이 질문에 코드입니다, [블랙 베리 - 이미지와 완전한 버튼을 차지 방법] (http://stackoverflow.com/q/4509519/396949), SO. – mrvincenzo

+0

버튼 아래가 아닌 화면 하단에 이미지를 표시하고 싶습니다. –

+0

@MrVincenzo 모든 예제 –

답변

1

나는 약간의 코드를 수정했습니다.

먼저 모든 디스플레이의 높이를 차지하고 필드를 수직으로 정렬하는 VerticalFieldManager이 추가되었습니다. VFM은 BitmapField를 제외한 모든 필드를 보유합니다. 그런 다음 이용 가능한 디스플레이의 높이의 나머지 부분을 차지하는 HorizontalFieldManager을 추가했습니다. 마지막으로 BitmapField가 스타일 FIELD_BOTTOM과 함께 HFM에 추가되어 HFM이 필드를 관리자의 맨 아래에 맞 춥니 다.

더 많은 이미지를 화면 하단에 추가하려면 FIELD_BOTTOM 스타일로 이미지를 인스턴스화하고 HFM에 추가하면됩니다.

필드 맞춤에 대한 자세한 내용은 answer을 확인하십시오. 여기

는 상기 수정

public NativeUI() { 
    //The background image. 
    backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png"); 

    MainScreen mainScreen = new MainScreen(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_HORIZONTAL_SCROLL); 

    VerticalFieldManager verticalFieldManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_HORIZONTAL_SCROLL | 
     Manager.USE_ALL_HEIGHT | Manager.USE_ALL_WIDTH) { 

     //Override the paint method to draw the background image. 
     public void paint(Graphics graphics) { 
      //Draw the background image and then call paint. 
      graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0); 
      super.paint(graphics); 
     }    
    }; 

    BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL); 

    //The LabelField will show up through the transparent image. 
    LabelField labelField = new LabelField("This is a label"); 

    HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT); 
    //A bitmap field with a transparent image. 
    //The background image will show up through the transparent BitMapField image. 
    BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png"), Field.FIELD_BOTTOM); 
    horizontalFieldManager.add(bitmapField); 

    //Add the fields to the manager. 
    verticalFieldManager.add(bef); 
    verticalFieldManager.add(labelField); 
    verticalFieldManager.add(horizontalFieldManager); 

    //Add the manager to the screen. 
    mainScreen.add(verticalFieldManager); 

    //Push the screen. 
    pushScreen(mainScreen); 
} 
+0

덕분에 아주 좋은 예가되었지만 이미지를 클릭 할 수있게 만드는 방법은 무엇입니까? –

+0

@sheetal_roswal 앞에서 언급했듯이 [BlackBerry - 이미지가있는 전체 버튼을 차지하는 방법] (http://stackoverflow.com/q/4509519/396949) 질문을 확인하십시오. 자신의 클래스를 만들고 질문 [대답] (http://stackoverflow.com/a/4509592/396949)에서 제기 된대로 BitmapField를 확장하십시오. – mrvincenzo

+0

감사합니다. @MrVincenzo –

1
hey it's very simple, just use **setStaus** method for displaying images/icons at the bottom of the screen in the blackberry... 
for example 

/** 
* Initialize Components 
*/ 
ButtonField btn1 = new ButtonField("Button 1"); 
ButtonField btn2 = new ButtonField("Button 2"); 
ButtonField btn3 = new ButtonField("Button 3"); 

HorizontalFieldManager hfm = new HorizontalFieldManager(); 
hfm.add(btn1); 
hfm.add(btn2); 
hfm.add(btn3); 


/** 
* Add Components to Screen 
*/ 
setStats(hfm); 

the setStatus is MainScreen Class method , you can directly use this method in any class that extends MainScreen. & you can find setStatus method in BB 5.0 & above 5.0 OS. 
for more info checkout this link :- 
http://www.blackberry.com/developers/docs/6.0.0api/index.html 
관련 문제