xml 事件监听和回叫方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 事件监听和回叫方法相关的知识,希望对你有一定的参考价值。

// Declaring a button, treating it as an object and finding the button that should be listened to by ID
Button button = (Button)findViewById(R.id.button);

// Event handling method (click)
        button.setOnClickListener(
          // Adding the listener
                new Button.OnClickListener(){
                  // Event executed method
                    public void onClick(View v) {
                      // Declaring a textView, treating it as an object and finding the textView that should change value when event is executed
                        TextView textView = (TextView)findViewById(R.id.textView);
                        // Changing the value of the textView
                        textView.setText("Clicked");
                    }
                }
        );
<?xml version="1.0" encoding="utf-8" ?>
<resources>
    <string name="button">Click</string>
    <string name="textView">Text</string>
</resources>

以上是关于xml 事件监听和回叫方法的主要内容,如果未能解决你的问题,请参考以下文章

Vue 页面跳转提示和回退问题

点击事件监听

Android 键盘事件触发以及监听

JavaWeb基础—监听器Listener

七seata客户端二阶段分支事务的提交和回滚

手把手教你入门web.xml:吃透监听器