问题
sorry for may be stupid question, I am a beginner. what can I do if I needed to extend both ListActivity
and FragmentActivity
in one activity?
I know that I can extend only 1 class, but is there any trick which resolves this?
Thank in advance.
回答1:
you don't have to extended list activity in order to use list , you can include list View inside your layout file
回答2:
No, you cannot extend 2 classes in Java. Could you specify why you need to extend both? My guess is FragmentActivity should suffice for your case.
回答3:
You cannot extend more than one class. You said you're beginner, whenever you dive deeper on how the objects work you'll see that it's simple impossible.
But, to answer the bigger picture of what you're probably trying to achieve:
You want to have one Class that will extend FragmentActivity, and a different class that will extend ListFragment. And whenever the FragmentActivity is created you'll instantiate one of your ListFragments and add it to the layout.
来源:https://stackoverflow.com/questions/11983578/android-combination-of-fragmentactivity-and-listactivity