1.定义全局变量
Button button;
Text text;
Button button2;
2.找到id 添加组件
button=(Button)findComponentById(ResourceTable.Id_button1);
button2=(Button)findComponentById(ResourceTable.Id_button2);
text=(Text) findComponentById(ResourceTable.Id_foringpwd);
button.setClickedListener(new MyListener() );
button2.setClickedListener(new MyListener());
text.setClickedListener(new MyListener());
3.新建一个类
public class MyListenerimplements Component.ClickedListener {//新建一个监听类并继承ClickedListener
@Override
public void onClick(Component component) {//点击执行的方法
Intent i=new Intent();
if (component==button){
Operation operation=new Intent.OperationBuilder()
.withAbilityName("")
.withBundleName("com.text1.douyinhome")
.withAbilityName("com.text1.douyinhome.cengong")
.build();
i.setOperation(operation);
startAbility(i);
}
网友评论