1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| public class SecondAbilitySlice extends AbilitySlice { @Override public void onStart(Intent intent) { super.onStart(intent); // 声明布局 super.setUIContent(ResourceTable.Layout_ability_second); ((Button)findComponentById(ResourceTable.Id_buttonReturn)).setClickedListener(new Component.ClickedListener() { @Override public void onClick(Component component) { onBackPressed(); } });
// DependentLayout myLayout = new DependentLayout(this); // // 设置布局大小 // myLayout.setWidth(MATCH_PARENT); // myLayout.setHeight(MATCH_PARENT); // // 设置布局背景为白色 // ShapeElement element = new ShapeElement(); // element.setRgbColor(new RgbColor(255, 255, 255)); // myLayout.setBackground(element); // // // 创建一个文本 // Text text = new Text(this); // text.setText("Hi there"); // text.setWidth(MATCH_PARENT); // text.setTextSize(100); // text.setTextColor(Color.BLACK); // // 设置文本的布局 // DependentLayout.LayoutConfig textConfig = new DependentLayout.LayoutConfig(MATCH_CONTENT,MATCH_CONTENT); // textConfig.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT); // text.setLayoutConfig(textConfig); // myLayout.addComponent(text); // super.setUIContent(myLayout); }
@Override public void onActive() { super.onActive(); } @Override public void onForeground(Intent intent) { super.onForeground(intent); } }
|