views:

37

answers:

1

I am new to android development and am currently working my way through the "Hello..." Tutorials on the developer website.

I got stuck on the Tab Layout walkthrough and the only way I could resolve it was to put each Activity Class in a separate .java file.

I was wondering if all Activities need to be in separate .java files, or am I missing something.

A: 

See this question. The answer is no, because Java does not allow it (with the exceptions discussed in the responses to my link).

cdonner
Cheers, I think I understand, should I be able to get it to work if I nest public Activity classes in the top level public class?
adustduke
Activity classes are public, so the answer is no again. There can only be one public class in a Java file and it must have the same name as the file.
cdonner
Why are you trying to get them into one file to begin with?
cdonner
Right, I am with you now. I just wanted one file which would have all the classes in it, I didn't realise that Activity Classes have to be public. Thanks.
adustduke