I'm making a very simple app, the main page has 5 buttons, each should open a new page with different text views and buttons, since I'm new to android I want to know what is the best practice for this situation?
Should I make every page as an activity ? Or will that take a lot of resources from the phone?
If you are going to have a view fill up the entire screen you should make each page an Activity.
Android manages itself the activity stack so you dont have to worry about.
Just make sure you declare it on the manifiest, or use the Android studio assistant to make a new activity.
Hope this helps.
Related
I'm new in Android Studio and I've been mostly learning through experimenting so it would be really appreciated if you could explain all the steps please.
I already have an app complete which has two Activities which are connected to each other. I made this in an Empty Activity. Now I want to this to have an Navigation Bar, what do I do?
I tried making a new Navigation Bar Activity and tried to copy paste everything, it worked for the layout file with the xml file but I can't where I should be putting in my code? I searched up numerous posts to no avail. My original code had over 300 lines so I really can't write it all over again. Can someone please help me out?
I'm doing this app in Java.
You'll need to use just one main activity and convert the current activities to Fragments. So if you've not heard of Fragments see here https://www.google.com/url?sa=t&source=web&rct=j&url=https://developer.android.com/guide/fragments&ved=2ahUKEwj7wpaxxJnvAhXCx4UKHf9tAqQQFnoECAMQAg&usg=AOvVaw13OtAaEKbecXytTb4qLxel
Then you can place a navigation bar widget on the main activity, this can be configured to the amount of fragments you need.
So here's the problem, when I create a new project using Basic Activity template it generates two fragments and every page or tutorial I've seen it's not generated. Is it something normal? How to I to avoid Android Studio creating this two fragments?
That started in version 3.6 of Android Studio. I believe they're trying to promote their Navigation Component, where the principle is to use one single Activity (host) and many Fragments (for all the other screens of the app).
As the other answers have suggested, you can either select "Empty Activity" instead or delete these fragments after they're created.
My suggestion would be to try and learn about the new Navigation Component, as it might become the new Standard in the near future.
I honestly don't know why Android Studio does that but if you want just one activity you can start with "Empty Activity" Or just "Add No Activity" option. And then add an activity with the App->New->Activity->Empty Activity.
Any help would be great with my issue. Basically I'm using this tutorial and its a web view fragment. So I got rid of the WebView and made new activities. My issue is connection the activities with the drawer so then every thing goes to a different activity. Once again, any idea on how to do this would be helpful.
I would recommend this tutorial instead.
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
I've used it and I have a functioning application at the moment. You can download the source, change the text and images if you'd like.
TL;DR version:
I want to add multiple instances of the same activity in my app and swipe through them.
I'm creating a home replacement app and I would like to know how to set up multiple home screens. I checked out the sample app provided in the SDK but it has only one screen.
I have almost everything set up but now realised that I couldn't figure out how to add multiple home screens and swipe through them. I'm just guessing that since the home screen is an activity, launchers add the same activity multiple times and let the user swipe through them. Is this correct?
What I can't figure out is how it does so and how it lets the user select the number of screens he/she wants and add/remove those activities again.
Can someone please help me out. Thanks a lot.
I think you want to use fragments. Checkout http://developer.android.com/guide/components/fragments.html
If you have specific queries on use of fragments, would love to help.
i am iOS app developer. Now when i created an app on iOS i want to do the same on android. With java i was familiar just now need some time to remember.
i was looking at some tutorial how to do one or other things. But what i can't find is the basics how everything works. How classes is interacting with each other.
For example i want to create registration window with few buttons and alerts.
I want registration window to be called just once when app is installed and just that.
Should i create new java class and few layouts, one for View with buttons and other for Alerts ?
Or should i create other class for alerts if i need them in other flow of my app ?
And how i should call that window with registration from my main class, which is
extends Activity
Also if there are some developers who came this road from objective-c (iOS) to java (android). It would be nice for some share experience how they did that.
Thank you for any help :)
Very few of the concepts in iOS and Android are similar. On Android you have Activites, Intendts the Manifest. When you design your layout it should be resolution independent. You have a search, back and a menu button and variable hardware. All of this has no equivalent in iOS.
That said, I think you just have to read the basic concepts and the getting started guide no matter if you come from iOS or never have done mobile development before.
EDIT
To answer your concrete question. Take a look at the lifecycle of an Activity and Preferences. With this, you could do some action on the first start of your main Activity and store some flag in the preferences when it's done. On the next start you just test that preference and skip the logic.
You can create one activity (.java file) and one layout(.xml file with buttons and input boxes) , alerts could be toast notifications:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html
All you require for this is a activity and a layout xml for that activity, this activity will be your main ie the entry point to your application, in that activity oncreate method you can check if it is registered or not by setting a flag or something which will direct to the next activity if its registered.
GOOD LUCK...
Just like your nibs in iPhone you create xml layouts in Android. And for view controllers here you make activity. One important thing is AndroidManifest.xml file, it contains all information of your app (like plist) plus all the activity information(Intent type and launcher methods).