开发者

Android with TabHost and Lists

开发者 https://www.devze.com 2023-03-28 19:28 出处:网络
I am writing an Android app that has a Tabs (3) Each Tab should have a listview I know that Java has a limitation of extending 1 class.

I am writing an Android app that has a Tabs (3)

Each Tab should have a listview

I know that Java has a limitation of extending 1 class.

My current code is

public class AlbumsActivity extends Activity {

I would like to do this

public class AlbumsActivity extends Activity, ListActivity {

I come from the world of 开发者_如何学JAVAiOS so multiple inheritence is OK in Obj-C but I know its a big NO NO in Java.

So how do I solve this? I know its possible because Spotify has done it


ListActivity is a subclass of Activity, so you can simply use:

public class AlbumsActivity extends ListActivity

and you will get all the methods from both classes.


It's enough to do:

public class AlbumsActivity extends ListActivity

ListActivity extends Activity anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消