I got a superclass like this:
public class SuperClass extends Activity
and a child class
public class ChildClass extends SuperClass
The SuperClass contains a function to set a layout
public void setTabBar(String layout){
inflater.inflate(...., ...);
}
The only thing that different in my child class and superclass is the layout. So over to my question:
Is there anyway I can send a String to the superclass method setTabBar("name of the layout")
; and then spesify the layout. I'v tried this:
public void setTabBar(String layout) {
int layoutFromString = Integer.parseInt("R.layout."+layout);
inflater.inflate(layoutFromString, null);
}
But this doesnt seems to work. Any ideas?
EDIT
As mentioned I tried this:
public void setTabBar(int id) {
inflater.inflate(id, null);
}
This will work for the SuperClass, but when I call the function from the child class like this:
public class TestClass extends SuperClass{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTabBar(R.layout.test);
}
}
LogCat only outputs this:
07-23 13:57:15.775: E/AndroidRuntime(7329): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)