[android开发]1秒学会给按钮加事件
作者:互联网
import android.os.Bundle; import android.widget.Button; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Button btn =findViewById(R.id.btn_next); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this, "HelloWorl", Toast.LENGTH_SHORT).show(); } }); } }
标签:Toast,学会,MainActivity,按钮,import,android,btn,View 来源: https://blog.csdn.net/weixin_41412410/article/details/120969427