2011-01-07 32 views

回答

2

我也遇到了同樣的問題,因爲我的要求也與您的要求相同,但在您未使用圖像但仍希望使用自定義標籤字段來傳遞某些參數的情況下,您可以使用我的方式。

import net.rim.device.api.system.Bitmap; 
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; 
import net.rim.device.api.ui.Keypad; 
import net.rim.device.api.ui.component.LabelField; 

public class MyCustomSubscriptionLabelField extends LabelField { 

    private Bitmap image = null; 
    private String customName = null; 
    private String key; 
    private String programName, startTime; 

    // Edited by vivek on 2010-11-18 to convert Basic Tv as Live tv i.e mapping 
    public MyCustomSubscriptionLabelField(String key, String customName, 
      long style) { 
     super("", FOCUSABLE); 
     if (customName == null) 
      this.customName = key; 
     else 
      this.customName = customName; 
     this.key = key; 
    } 

    public MyCustomSubscriptionLabelField(String programName, String startTime, 
      String customName, long style) { 
     super("", FOCUSABLE); 
     this.programName = programName; 
     this.startTime = startTime; 
    } 

    public void setText(String text, int offset, int length) { 
     // super.setText(customName, image.getWidth(), customName.length()); 
     super.setText(text); 
    } 

    public void paint(Graphics graphics) { 

     super.paint(graphics); 
    } 

    public String getCustomName() { 
     return customName; 
    } 

    public String getKey() { 
     return key; 
    } 

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

    protected boolean keyChar(char character, int status, int time) { 
     if (character == Keypad.KEY_ENTER) { 
      fieldChangeNotify(0); 
      return true; 
     } 
     return super.keyChar(character, status, time); 
    } 

    public void setProgramName(String programName) { 
     this.programName = programName; 
    } 

    public String getProgramName() { 
     return programName; 
    } 

    public void setStartTime(String startTime) { 
     this.startTime = startTime; 
    } 

    public String getStartTime() { 
     return startTime; 
    } 
} 

使用此自定義標籤字段類使用setText設置任何長文本;

customSubscriptionLabelField[j]= 
    new CustomSubscriptionLabelField("","Value tht u want to pass and retrive",style); 
customSubscriptionLabelField[j].setText("Any Long text will be wrapped to new line ",0,text.length()); 

希望這將幫助ü在一些地方

+0

謝謝維韋克烏拉圭回合help.I正在實施it.will讓你知道 – arunabha 2011-01-07 17:44:47

+0

喜不將其標記爲回答如果它可以幫助你,讓我知道如果你實現你的照片與文字自定義labelfield – 2011-01-08 06:52:50

0

嘿,我發現多了一個解決我們的問題。 添加圖片到hfm1 添加labelField屬性hfm2 現在添加hfm1和hfm2到VFM 現在這個VFM添加到屏幕上,這將像用圖片和文字,並最有可能的標籤字段的服務於我們的目的