Android - Handling A Grid
I am trying to make a 2x2 grid of buttons and handle them. Right now I have a relative view activity with four buttons...but my question is: is the best way to do this? Than give e
Solution 1:
First of you you can do
public class YourActivity extends Activity implements OnClickListener {...
and then implement the onClick method as
@Override
public void onClick(View view) {
switch(view.getId()){
case R.id.A_UI_Element:
//do what you need for this element
break:
case R.id.A_Different_UI_Element:
//do what you need for this element
break;
//continue with cases for each element you want to be clickable
}
}
Post a Comment for "Android - Handling A Grid"