Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Button
1. public class MainActivity extends AppCompatActivity implements
View.OnClickListener{ // 1. implemet listener
Button boton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
boton =(Button)findViewById(R.id.Mybutton); //-------2 connect button
with xml
boton.setOnClickListener(this); //---------3. put listener to button
}
public void onClick(View v) {
switch (v.getId()){
case R.id.Mybutton: //----- 4. Using one lister for all buttons,
select what happends for each button
//----what button is gonna do!
break;
}
}
}