Android中关于多个按钮放在一起操作的方法
关于多个按键放在一起操作的方法:
public class Sudoku extends Activity implements OnClickListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.main); super.onCreate(savedInstanceState); View continueButton=this.findViewById(R.id.continue_button); continueButton.setOnClickListener(this); View newButton =this.findViewById(R.id.new_button); newButton.setOnClickListener(this); View aboutButton=this.findViewById(R.id.about_button); aboutButton.setOnClickListener(this); View exitButton=this.findViewById(R.id.exit_button); exitButton.setOnClickListener(this); } public void onClick(View v) { switch(v.getId()){ case R.id.about_button: Intent i=new Intent(this,About.class); startActivity(i);
如果,这篇博客帮您解决了问题,不妨点击一下右下角的【推荐】。如果,您希望更容易地发现我的新博客,不妨点击一下【加关注】。因为,我的热情需要您的肯定和支持!感谢您的阅读,如果文章中有错误或者您有什么好的建议,也欢迎您直接留言批评指教。Thanks,friends! |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步