I have the interface where I have to use buttons not list not anything but buttons. I was wondering if there's a away to group the buttons by ids instead of looping in the switch(which is very long) because of my many buttons. Normally If its a listview adapter I would do something like this if am in an adapteview
String[] clickitems = getResources().getStringArray(R.array.array) ;
String toclasses = clickitems[position] ;
try {
Class classes = Class.forName(getPackageName()+"."toclasses);
Intent intent = new Intent(Main.this, classes);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) ;
startActivity(intent) ;
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
Now i would like to use the same method for getting the clicked button using v.getId() as the array to use instead of the position for that case. Instead of
switch(v.getId()){
case R.id.xxx:
break;
}
Any ideas on how to approach it that way