1c7 / VideoList

:us: -> :cn: @糖醋陈皮 翻译的视频列表
https://weibo.com/2004104451
57 stars 11 forks source link

网页,安卓,iOS的事件监听 #85

Open 1c7 opened 8 years ago

1c7 commented 8 years ago

网页

先给 HTML 元素一个 ID

<div id="nice">haha</div>

然后用 Javascript 的 document.querySelector 或者 document.getElementByID 获取元素然后监听事件

var the_one = document.querySelector("#nice");
the_one.addEventListener("click", function(){
    console.log("哈哈")
});



Android 里是

先给控件元素一个 ID

Button buckButton = (Button)findViewById(R.id.hahaButton);
buckButton.setOnClickListener(
new Button.OnClickListener(){
public void onClick(View v){
                TextView cText = (TextView)findViewById(R.id.hahaText);
                cText.setText("aofuaudofh ");

            }
        }
);



iOS

未完待续