An extend and import issue - Android
Here is the deal : I need to extends two different classes in Android. An example: In MainActivity.class I need to extends first TabActivity to use the tabs and getTabHost(); and in the same class I need to extends for example Li开发者_如何学PythonstActivity or something else...How can I do that? Maybe my question is a little stupid but... Thanks anyway!
You can extends either TabActivity or ListActivity in your main Activity.You can't extends two all together because java does not support multiple inheritence.After extending any one create the reference of another to use in your activity.
Your MainActivity
doesn't need to extend TabActivity
and ListActivity
at the same time.
Only MainActivity
needs to extend TabActivity
and you can use a different Activity
which extends ListActivity
as the content of one or more of the tabs.
Here is the really good official documentation which has an example of what I'm talking about : http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
精彩评论