"deviceType": ["tv" ]
"deviceType": ["wearable" ]
"deviceType": ["tv","wearable" ]
public void onStart(Intent intent) {
super.onStart(intent); LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT); myLayout.setLayoutConfig(config); ShapeElement element = new ShapeElement(); element.setRgbColor(new RgbColor(255, 255, 255)); myLayout.setBackground(element); Text text = new Text(this); text.setLayoutConfig(config); text.setText("Hello World"); text.setTextColor(new Color(0xFF000000)); text.setTextSize(50); text.setTextAlignment(TextAlignment.CENTER); myLayout.addComponent(text);super.setUIContent(myLayout); }
if(DeviceInfo.getDeviceType().equals("tv")) { ... ...} else if(DeviceInfo.getDeviceType().equals("wearable")) { ... ...}
public void onStart(Intent intent) { super.onStart(intent); LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT); myLayout.setLayoutConfig(config); ShapeElement element = new ShapeElement(); element.setRgbColor(new RgbColor(255, 255, 255)); myLayout.setBackground(element); Text text = new Text(this); text.setLayoutConfig(config);if(DeviceInfo.getDeviceType().equals("tv")) { // 運行在TV上執行的代碼 text.setText("華爲智慧屏"); text.setTextColor(new Color(0xFFFF0000)); text.setTextSize(200); } else if(DeviceInfo.getDeviceType().equals("wearable")) {// 運行在Wearable上執行的代碼 text.setText("華爲智能手錶"); text.setTextColor(new Color(0xFF0000FF)); text.setTextSize(50); } text.setTextAlignment(TextAlignment.CENTER); myLayout.addComponent(text); super.setUIContent(myLayout); }
- EOF -javascript
1. 比Python更牛的語言有嗎?看我用元類(metaclass)花式建立Python類java
2. 見鬼!導入Python模塊執行了全部代碼,你不知道__name__變量是什麼意思嗎?
web
3. 連Python產生器(Generator)的原理都解釋不了,還敢說Python用了5年?編程
4. 牛掰了!鴻蒙與Android完美融合,將鴻蒙設備當Android設備用json
關注「極客起源」公衆號,加星標,不錯過精彩技術乾貨
ui
本文分享自微信公衆號 - 極客起源(geekculture)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。this