我在針對圖標顯示通知計數時遇到問題。它應該顯示在右上角。在CodaNameone中顯示通知計數
首先創建帶有填充和邊距爲零的按鈕並將圖像設置爲按鈕。
FlowLayout buttonLayout = new FlowLayout();
buttonLayout.setAlign(Component.CENTER);
buttonLayout.setValign(Component.TOP);
Container buttonContainer = new Container(buttonLayout);
buttonContainer.setUIID("IconContainer");
Button button = new Button(buttonImage);
button.setUIID("ButtonLabelNew");
buttonContainer.addComponent(button);
所創建的通知計數容器,把它在按鈕
FlowLayout countLayout = new FlowLayout();
countLayout.setAlign(Component.RIGHT);
countLayout.setValign(Component.TOP);
Container countContainer = new Container(countLayout);
Label countLabel = new Label(displayCount);
countLabel.setUIID("backgroundLabel");
countContainer.addComponent(countLabel);
/*Adding Button and Notification Count to ItemContainer*/
Container itemContainer = new Container(new LayeredLayout());
itemContainer.addComponent(buttonContainer);
itemContainer.addComponent(countContainer);
立即添加的按鈕
BoxLayout iconLayout = new BoxLayout(BoxLayout.Y_AXIS);
Container iconContainer = new Container(iconLayout);
Label iconText= new Label(buttonText);
iconText.setUIID("Label");
iconContainer.addComponent(0,itemContainer);
iconContainer.addComponent(1,iconText);
最後創建的格下面的文本和添加的圖標的容器到電網
GridLayout gridLayout = new GridLayout(numRows, MAX_ITEMS_PER_ROW);
Container gridContainer = new Container(gridLayout);
gridContainer.setUIID("LogoContainer");
for (int indx = 0; indx < itemContainers.length; indx++)
{
gridContainer.addComponent(itemContainers[indx]);
}
approvalsWorklist.addComponent(BorderLayout.CENTER,gridContainer);
什麼不在這裏工作?這似乎是正確的大部分。你能否提供你所得到的截圖,並解釋爲什麼它與你期望的最終結果不同? –
Shai我在這裏發佈圖片(https://www.dropbox.com/s/6wep74gq4oxoe60/grid.png) – user3304328
問題是通知計數並不出現在確切的右上角。這裏有一個餘地。 – user3304328