2013-06-18 3 views
1

저는 BlackBerry 프로그래밍에 익숙하지 않습니다. 음악 플레이어 에서처럼 왼쪽의 Bitmap, 제목 및 부제와 함께 클릭 가능한 목록보기를하려고합니다. 내가이 화면을 누를 때 나는 오류가 오전 :TablelayoutManager, 사용자 지정 목록을 만드는 방법?

"Field added to manager while it is already parented."

여기 내 코드입니다 :

public class Tab_Main extends MainScreen 
{ 
    public Tab_Main() 
    { 
     Bitmap bitmap1 = Bitmap.getBitmapResource("logo.png"); 
     Bitmap bitmap2 = Bitmap.getBitmapResource("logo.png"); 
     bitmap1 = resizeBitmap(bitmap1, 55, 55);   
     bitmap2 = resizeBitmap(bitmap2, 55, 55); 
     LabelField t_text = new LabelField("Massala SoftWares"); 
     LabelField m_text = new LabelField("Hello World"); 
     BitmapField logo = new BitmapField(bitmap2); 
     TableLayoutManager outerTable = new TableLayoutManager(new int[] 
       { 
       TableLayoutManager.USE_PREFERRED_SIZE, 
       TableLayoutManager.SPLIT_REMAINING_WIDTH 
       },0); 
     TableLayoutManager innerTable = new TableLayoutManager(new int[] 
       { 
       TableLayoutManager. USE_PREFERRED_SIZE, 
       TableLayoutManager.USE_PREFERRED_SIZE 
       }, Manager.USE_ALL_WIDTH); 

     innerTable.add(t_text); 
     innerTable.add(m_text); 
     innerTable.add(new LabelField("Description")); 
     innerTable.add(new LabelField("Description Link")); 
     innerTable.add(new LabelField("Rating")); 
     innerTable.add(logo); 

     outerTable.add(logo); 
     outerTable.add(innerTable); 

     super.add(outerTable); 
    } 

    public static Bitmap resizeBitmap(Bitmap image, int width, int height) 
    { 
     int imageWidth = image.getWidth(); 
     int imageHeight = image.getHeight(); 

     // Need an array (for RGB, with the size of original image) 
     int rgb[] = new int[imageWidth * imageHeight]; 

     // Get the RGB array of image into "rgb" 
     image.getARGB(rgb, 0, imageWidth, 0, 0, imageWidth, imageHeight); 

     // Call to our function and obtain rgb2 
     int rgb2[] = rescaleArray(rgb, imageWidth, imageHeight, width, height); 

     // Create an image with that RGB array 
     Bitmap temp2 = new Bitmap(width, height); 

     temp2.setARGB(rgb2, 0, width, 0, 0, width, height); 

     return temp2; 
    } 

    private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2) 
    { 
     int out[] = new int[x2*y2]; 

     for (int yy = 0; yy < y2; yy++) 
     { 
      int dy = yy * y/y2; 
      for (int xx = 0; xx < x2; xx++) 
      { 
       int dx = xx * x/x2; 
       out[(x2 * yy) + xx] = ini[(x * dy) + dx]; 
      } 
     } 
     return out; 
    } 
} 

답변

1

당신은에 logo를 추가하는 모두 당신의 innerTableouterTable.

A Field can only be added to one Manager (container) at once. 두 번째 관리자에 필드를 추가하면 오류가 발생 무엇 :

Field added to manager while it is already parented.

이 상황에서 TableLayoutManagerlogo 필드의 부모입니다.

간단하게 예를 들어, add(logo) 하나의 호출을 제거 : 당신은 ... 그것은 작동

innerTable.add(logo); 
+0

감사합니다 (죄송합니다 영어 좋지 IAM). –

관련 문제