I have a tab setup as an Activity extension using API8 max.
In this tab, I’m initializing some TextView, EditText and SeekBar objects like below.
I’m looking for a more universal method to be able to use a single method to initialize various object types (i.e. TextView, EditText, SeekBar and so on), passing the View type and id as argument, instead of using one method per View type.
In short, how to replace the 2 methods setTextViewObjects and setSeekbarObjects by a single generic method ?
private void initView(){
mUnits = setTextViewObjects(R.id.textView16);
mSeekBar = setSeekBarObjects(R.id.seek);
}
/**
* Set TextView objects
*/
private TextView setTextViewObjects(int id){
return (TextView) findViewById(id );
}
/**
* Set Seekbar objects
*/
private SeekBar setSeekBarObjects(int id){
return (SeekBar) findViewById(id );
}
This should do what you want: