{final Button tab3button2 = view findViewById(R.id.button2); View.OnClickListener() { @Override pubilc void onClick (View v)
我试着寻找答案,但都无济于事。
发布于 2021-05-03 14:25:15
只需复制on click源代码的代码,你必须有一个像bindview或webview这样的部分来获取widget的id。然后只需输入I'd,确保它不同于同一页面上的所有其他内容。
发布于 2021-11-30 18:41:38
这是你需要的,我编辑了你的代码:
final Button tab3button2 = view findViewById(R.id.button2);
tab3button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _view) {here put the blocks that will be executed when the button gets clicked
}
});建议将此代码添加到onCreate事件中,但如果此Button位于ListView自定义视图中,则将其添加到onBindCustomView事件中。
https://stackoverflow.com/questions/67074060
复制相似问题