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(); } }); } }