I have been away from Android app creation for quite a while and has just recently begun my new App.
Now i thought i would test out this new Android Studio and therefore downloaded it.
When i started my project it asked for a fragment and i wasnt quite sure what it ment (i know what a fragment is!).
When it started the project i had a activity_main and a fragment_main. And now every time i want to create a new activity it requires me to create an additional fragement.
Can anyone explain to me why this is happening (maybe ive missed something).
Fragments are part of Google's UI design philosophy since Honeycomb (see embedded link).
If you would like to work around the default activity template in Android Studio, then check out this blog post.
To add an Activity without a fragment, select File->New->Activity->Empty Activity
Related
In Android Studio, when creating new basic activity and when clicked Finish, it didn't create a basic activity but just empty activity.
I don't have idea what's wrong with my project settings because I didn't change anything (just moving package from one to another).
In my other Android projects, there's no such bug and I can create basic activity.
You need to lower your API below 28 until this activity is working correctly.
Does anybody know why the blank activity in the latest version of Android Studio now includes two .xml files for each Activity? My instinct is to use Empty Activity and continue doing things "the old way" but I'm wondering what Android's "bigger picture" is with these changes? Is it wiser to develop any future applications using this new Blank Activity format? Thank you.
Does anybody know why the blank activity in the latest version of Android Studio now includes two .xml files for each Activity?
For Android Studio 1.5, content_main.xml contains the core UI of the activity. activity_main.xml wraps that in a bunch of other stuff (e.g., CoordinatorLayout) to demonstrate a couple of particular UI elements (e.g., FAB). activity_main uses <include> to incorporate content_main by reference.
These templates change occasionally, and so if you are reading this in the future, your edition of the templates may differ substantially (and please stop reading Stack Overflow answers from your flying car, as that's a safety hazard).
I'm wondering what Android's "bigger picture" is with these changes?
IMHO, you are seriously overstating the role of these templates. They are samples, nothing more.
Is it wiser to develop any future applications using this new Blank Activity format?
It is wiser to not pay all that much attention to the templates. They are samples, nothing more. Developers should know what they want to build and how they want to build it. If one of the templates is close to what is desired, use it. Otherwise, skip the new-activity wizard entirely and just add the new activity yourself.
In cases where the new-activity logic is not directly avoidable (e.g., new-project wizard), either use "Empty Activity" (as it has the least stuff that you would need to delete) or find some other solution. For example, other than for experimenting with the new-project wizard itself, I never use it, and I make a few Android projects a week. Instead, I'll copy an existing project and adjust it to the new package name and stuff, then import it into Android Studio, as I find that less irritating than having to rip out template-generated gunk.
If you choose Blank Activity then you will have the option of having the activity use a Fragment. Also, Android Studio will automatically create two layout files for the activity, three if you choose the Fragment option, and also a menu resource file.
If you choose Empty Activity then you get to choose whether or not you want Android Studio to generate a layout file for the activity. If you choose the layout file option Android Studio will create one layout file, as opposed to two layout files in case of Blank Activity, and no menu resource file. Also, the layout file is much simpler and does not contain things like: Coordinator Layout, Floating Action Button, etc., whereas the layout file for Blank Activity contains these items, assuming you are using the latest version of Android Studio.
I have an android application in android studio, and this app has about 10 activities (or user interfaces).
I can't find where and how I could view the sequence diagram of the activities (or ui) of my android studio application.
I'm looking a plugin for android-studio or something like that. At one point earlier in my usage of android-studio, I seem to recall being able to pressed a button and get to the the UI-sequence-diagram. I can't find that now.
Could anyone offer any help for viewing the sequence diagram of my user-interfaces of my app?
Unfortunately, there is no "one button" solution that interrogates your code and spits out a diagram any longer. There was once an experimental feature that was later removed from Android Studio.
But starting with Android Studio 3.3, you can create your application using Navigation Component, which gives you the diagram you're after.
You define the Navigation graph, which results in an XML file that has all of your navigation specifics. If you go through the trouble to recode your application to use NavController (and the related components), you not only get the diagram, but this scheme takes care of a lot of up and back actions automatically, and lets you pass data between activities with ease.
Try Tools -> Android -> Navigation Editor
I just started out with learning how to use MVVMCross with Android using Xamarin Studio. I am fairly new to Android development.
I am porting an iOS app to Android and when I rotate my screen my app crashes when using fragments. I thought the problem was just me doing something wrong but when I run the sample project attached to the sample video the same thing happens. The error i get is " No default constructor found".
The Sample app I used at github : https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/Fragments
Can someone please help me out to why this is happening ?
After some digging, I "think" you are asking about how to handle rotation for a DialogFragment - I hope I've got that right.
If you do want to handle rotation in Android, then you have to:
provide the default constructor and you have to make use of the fragment tag
provide some code in the Activity.OnCreate handler in order to ensure that the DialogFragment has its ViewModel set after the rotation occurs.
I've just done this for the sample you mention in this commit - https://github.com/MvvmCross/MvvmCross-Tutorials/commit/ebe1777ec79ee2607b1b863f6b8b3911c12df53f
Note that to really fully support the Activity lifecycle - e.g. including loading/saving state when the App or Activity is "tombstoned" - then you should also go further than this - should save/restore all View and ViewModel state. MvvmCross does contain some helpers for this in the SaveState and ReloadState ViewModel methods - but even with these then fully supporting the Activity lifecycle can be quite a pain (which is why some apps don't fully support it, but instead show a "new" display instead)
I recently started using Android Studio instead of Eclipse. Previously I made a widget in Eclipse and when switching to Android Studio, I could easily open it there.
However, I can't quite figure out how to create a blank widget in Android Studio. When creating a new project in Android Studio I can choose between a Blank Activity, a Fullscreen Activity or a Master/Detail Flow. Since I'm making just a widget and not an activity the first two aren't the right ones and the third one doesn't seem to be what I want either.
Hi I can see this might be an old question but. Hope this helps newbies...
I am using Android Studio 1.0.2 and has some awesome features to generate most of the stuff that if you follow many tutorials out there. Is just a click away. On android studio i'm using just right click, select new and Widget App > then every file needed is generated for you based on the size of widget you want.
Happy coding .... !
When you create a new project, just uncheck the "Create activity box"