Adding a new class to Android Project - android

I'm a long time windows developer looking to learn something about Android programming. I'm working my way through the Sams book Teach Yourself Android Application Programming in 24 hours. I've discovered some flaws with the book already but nothing that I couldn't figure out on my own, until now. I'm working on adding a second class to my project and in the New Java Class dialog, it says to click the Browse button next to the Superclass box and pick "android.app.Activity". However, the only thing shown is java.lang.Object.
I'm pretty certain that I've set thing up correctly, but then, maybe I haven't.
Can anyone give me guidance?
Thanks!
Bo

The browse button tries to do an auto-match based on what is currently in the Superclass text box.
Delete java.lang.Object and enter Act (for example) then click Browse and see what you get. ;-)
BTW - I'm assuming you're using Eclipse? If so, confirm and someone will retag the question as it's more of an Eclipse usage question rather than Android specific.

After creating a class you can just extend it ..
Create a class and then manually add the part in bold
public class MyActivity extends android.app.Activity{
}

Related

Regarding Android studio, how do you display the built in class files?

I know there's some way to do this because i've done it by accident, I just don't know the proper terminology to use in a google/SO search, so my apologies. For instance: the View class, a built in Android class, how can I bring up the file inside Android Studio with all the methods etc to see how the class works? and yes I'm aware I can just go to android.developer.com and see everything, but thats not my question.
I think you're talking about going to the class declaration. On Mac you can hold down Command and click on the class you want to go to, for Windows and Linux you can hold Control and click on the class.
https://developer.android.com/studio/intro/keyboard-shortcuts.html

Confused with MainActivity.java in android studio

I'm fairly new to java and android studio in general,and I'm trying to follow a tutorial on YouTube on how to make a simple android calculator by Andy York. I made it to part 2 of 2 until he started coding in MainActivity.java, when I noticed that ours were different and that I have stuff like "FloatingActionButton"and "SetSupportActionBar" which he doesn't have and which is confusing because if erase those then everything will mess up. I think it may have been because of an Android Studio update since his video? I'm trying to make everything neat like his but I don't know how. I hope this makes sense and any help would be appreciated. Thanks.
When creating new project in Android Studio use "Empty Activity" template instead of "Basic Activity". The "basic" one does add a lot of things, like a floating action button, which often isn't helpful.
Those are coming because you select a that theme. So, Select the Empty Activity. Then nothing will make problem .

android studio - default constructor?

I need your help. I created an app in Android Studio, then I created a second "page", well I created a second class.
But it says this class needs an default constructor. What shall I do?
I hope you can help.
Cheers
Follow a tutorial if you are new to Android Development.
https://androidcookbook.com/Recipe.seam?recipeId=1670
Could help you understand the flow better. Google is your friend, don't be afraid to search if you need tutorials.

writing extended class methods in android Studio

Just migrating Eclipse to Android Studio, and struggling a lot without knowing much shortcuts and import the extended class methods such as "Right Click-> Source->Override/Implement Methods" then we implement methods. Here I found no Source option. How may I include those methods. plz help me to get this quickly, as now I'm typing them .
In Android Studio the menu you're looking for is Code. You then can select what types of methods you need generated.

Eclipse doesn't offer to add import or show functions for android objects

Somehow I've screwed up my Eclipse installation. Used to be if I added a new instance of an Android object (say a TextView) and I right clicked on the error, it would offer to add the import. Also if I had an Android object and typed it followed by a period, it would show me all the allowed functions. Now it doesn't do either, just shows me java info. Don't know what I did, since this used to work. I updated everything, but still no joy. Can anyone help me get this back to the way it was?
Thanks,
Dan
Check your settings in Window->Preferences->Java->Editor->Content Assist

Categories

Resources