使用文件預先渲染界面
// 定義界面
@ViewDescriptor(
name = "Main View", // 界面標題
rows = 1, // 界面行數
patterns = "ZZZZAZZZZ", // 界面的樣式
cancelMove = 'A' // 需要取消移動的 pattern
)
public class MainView implements View<String> { // 此界面裝載 String 作為數據
@Override
public void renderView(String s, UIContext context) {
ButtonFactory button = context.factory(ButtonFactory.class); //獲取 按鈕組件工廠
context.pattern('A') // 指定 Pattern A
.components( // 放入組件
button.icon(Material.DIAMOND_BLOCK) // 設置鑽石方塊
.title(s) // 設置顯示
.create() // 創建組件
);
}
}創建文件
最后更新于