0

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.

adustduke
  • 155
  • 1
  • 8

1 Answers1

1

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

Community
  • 1
  • 1
cdonner
  • 37,019
  • 22
  • 105
  • 153
  • 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 Sep 08 '10 at 16:37
  • 1
    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 Sep 09 '10 at 01:50
  • Why are you trying to get them into one file to begin with? – cdonner Sep 09 '10 at 01:50
  • 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 Sep 09 '10 at 12:05