赞
踩
首先在ability_main.xml中添加一个Button和Text。`
<Button
ohos:id="$+id:but1"
ohos:height="match_content"
ohos:width="match_content"
ohos:text="点我"
ohos:text_size="200"
ohos:background_element="red"
/>
<Text
ohos:height="match_content"
ohos:width="match_content"
ohos:id="$+id:text1"
ohos:text="text"
ohos:text_size="100"
/>
实现步骤
Button but1=(Button)findComponentById(ResourceTable.Id_but1);
text1=(Text)findComponentById(ResourceTable.Id_text1);
but1.setDoubleClickedListener(this);
public class MainAbilitySlice extends AbilitySlice implements Component.DoubleClickedListener{...}
@Override
public void onDoubleClick(Component component) {
// component 表示点击组件的对象
text1.setText("被双击了");
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。