美文网首页
按钮和文本跳转链接的方法

按钮和文本跳转链接的方法

作者: 游私塾白书生 | 来源:发表于2022-05-13 23:26 被阅读0次

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);

        }

相关文章

网友评论

      本文标题:按钮和文本跳转链接的方法

      本文链接:https://www.haomeiwen.com/subject/wyfpurtx.html