2011-06-02 90 views
0

先生您好我米將某個應用中,我陷入了一個問題,請大家幫我出...如何更改場焦點黑莓

在一個

頁即時得到來自服務器和顯示的數據在頁面上的數據現在我使用Focusable突出顯示它們...現在我的要求是,當焦點來到任何數據時,它應該改變該字段的名稱,其中重點是目前..

以下是代碼正顯示出頁面,我們正在場變化,我需要點擊標籤字段中的數據....

static LabelField[] CrDrLabels; 

    public LowerCreditors() throws Exception { 

     super(VerticalFieldManager.VERTICAL_SCROLL); 

     CrDrLabels = new LabelField[CrDrList.VendorNameArr.length]; 

     for (int i = 0; i < CrDrLabels.length; i++) { 
      final int t = i; 

      VerticalFieldManager hfm = new VerticalFieldManager(USE_ALL_WIDTH) { 

       protected void sublayout(int Width, int Height) { 

        // TODO Auto-generated method stub 

        super.sublayout(Width, Height); 

        setPositionChild(getField(0), 15, 0); 

        setPositionChild(getField(1), Display.getWidth() 
          - getFont().getAdvance(CrDrList.VendorValArr[t]) 
          - 10, 0); 
       } 
      }; 

      CrDrLabels[i] = new LabelField(CrDrList.VendorNameArr[i], 
        LabelField.FOCUSABLE | Field.USE_ALL_WIDTH) { 
       protected boolean navigationClick(int status, int time) { 
        fieldChanged(this, 0); 
        return true; 
       }; 
      }; 

      LabelField Value = new LabelField(CrDrList.VendorValArr[i]); 
      CrDrLabels[i].setPadding(0, 170, 0, 0); 

      hfm.add(CrDrLabels[i]); 
      hfm.add(Value); 

      add(hfm); 


     } 
    } 

    public void fieldChanged(Field field, int context) { 

     // TODO Auto-generated method stub 
     for (int i = 0; i < CrDrList.VendorNameArr.length; i++) { 
     getFieldWithFocus(); 
      if (field == CrDrLabels[i]) { 

       String LN = CrDrLabels[i].getText(); 
       CrDrList.cname1 = LN; 

       LabelField cname1 = CrDrLabels[i]; 
       CrDrList.selLad = CrDrLabels[i]; 

      } 

     } 
    } 

和其它代碼是

menu.add(new MenuItem("View last 5 days transaction", 20, 10) { 
      public void run() { 
       if(property.Status.equals("online")) 
       { 
       Viewlast5daystransaction(); 
       } 

       else 
       { 
        Dialog.alert("Please login Online to access the data.."); 
       } 
      } 

      String LedgerName = CrDrList.cname1; 

      private void Viewlast5daystransaction() { 
       //Dialog.alert("Last 5 Days Transaction"); 

       int resCode = 0; 

       HttpConnection connection = null; 
       try { 
        connection = getConn(property.LedgerDetailsURL); 
       } catch (Exception e1) { 
        // TODO Auto-generated catch block 
        System.out.println(e1.getMessage()); 
        e1.printStackTrace(); 
       } 

       try { 
        resCode = connection.getResponseCode(); 
       } catch (Exception e1) { 
        // TODO Auto-generated catch block 
        e1.printStackTrace(); 
       } 

       if(resCode==0) 
       { 
        Dialog.alert("Internet Connectivity not available.. Please try again later.."); 

        TallyA TA; 

        try { 
         TA = new TallyA(); 

         UiApplication.getUiApplication().popScreen(); 
         UiApplication.getUiApplication().pushScreen(TA); 
        } catch (Exception e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 
        } 

       } 

       sPostdata = "{\"tok\":\"" 
         + CompanyList.tok; 

       System.out.println("Postedddddd Dataaaaaaaaa" + sPostdata); 
       try { 
        String response = LedgerSearchReport(); 

        System.out.println("response" + response); 

        ParseBankdetails.parsebankdetails(response); 

        System.out.println("response : " + response); 

        if(response != null) 
        { 
        LastFiveDaysCr LF; 
        try { 
         LF = new LastFiveDaysCr(); 

         UiApplication.getUiApplication().pushScreen(LF); 
        } catch (Exception e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 
        } 
        } 

        else 
        { 
         Dialog.alert("No Data.."); 
         Creditiors LF; 
         try { 
          LF = new Creditiors(); 

          UiApplication.getUiApplication().pushScreen(LF); 
         } catch (Exception e) { 
          // TODO Auto-generated catch block 
          e.printStackTrace(); 
         } 
        } 

       } 
       catch (Exception e) { 

        e.printStackTrace(); 
       } 

      } 
     }); 
在這一領域

只是我想,而不是場變化應該有重點的變化...... 請幫我上......

回答

1

我想應實現邏輯 「onFoucus()」 的方法,而不是使用 「onfieldChanged()」 爲CrDrLabels [I];

+0

你好先生,我嘗試了很多這樣做,但它沒有發生我不是能夠做到這一點.....我已經取得2個不同的類打印特定頁面,我想如果CrDrLabels [I]任何焦點會然後從菜單按鈕,我可以執行任何任務....就像我可以將請求發送到服務器...請大家幫我上... – 2011-06-06 06:57:53

+0

你試圖執行代碼上的onfocus()方法處理事件。? – 2011-06-06 07:17:00

+0

是的,先生我已經嘗試了也....請幫助我,並就一些代碼... – 2011-06-06 07:20:41