I am working on mvvmcross framework and try to learn it. I have some difficulties when to develop Android project.
I have a main page where everything happens, and I want to put a Login Screen Model on top of that. I do not want to do them as activities because I do not want to destroy the main page to show login page. I just want to show a model on top of that
In iOs this can be done by using Presenter. How can i use the same method for android? Any suggestions? Thanks in advance.
I'd use a Presenter for this too - just use that presenter to show a dialog or fragment (or dialogfragment) rather than an activity in this case.
The default Presenter MvvmCroos provides in Android is Activity based - but it's easy to override it so that it shows different types of things in different scenarios. Search for custom presenters in Android MvvmCross for more info (I'm on mobile typing right now - so can't easily add links)
Related
I have a native Android app that I am translating to Flutter, and I am not sure that I'm on the right track. I implemented the bottom navigation bar functionality by following the documentation, but I'm not sure what's the best way to navigate between what were Fragments in the native android project. For every widget I select with the BottomNavBar, I need further "pages", while the BottomNavBar has to stay on the screen, and I also need to pass data further "down" the navigation graph.
I thought about creating a custom widget which stores the subpage you are on, same way as I did with the BottomNavBar, but this seems like a hack, especially that I would also have to store the parameters that I have to pass to the new "fragment", and the pages should keep their state after navigating away and back.
Is there a better way to implement this functionality?
I use the IndexedStack as this article elaborates. I think it's probably a good solution.
https://pub.dev/packages/persistent_bottom_nav_bar/
It occurred to me after asking that I should check for a package, and here it is, does what I need.
I am a beginner in android development. I am currently reading about Fragments from developer.android.com and this showed up about DialogFragment:
DialogFragment
Displays a floating dialog. Using this class to create a dialog is a good alternative to using the dialog helper methods in the Activity
class, because you can incorporate a fragment dialog into the back
stack of fragments managed by the activity, allowing the user to
return to a dismissed fragment.
Can anybody explain this to me ? Thanks
The fragment is lightweight and easy to implement. You need to style your activity to display a dialog. First, you have to understand the difference between activity and fragment.
Activity:
Activities have been around for a very long time and are used to
construct a single screen of your application. When someone is using
your Android application, the views that the user sees and interacts
with are hosted and controlled by a single activity. Much of your code
lives in these Activity classes, and there will typically be one
activity visible on the screen at a time.
Fragment
Fragments are another type of controller class that allows us to
separate components of our applications into reusable pieces.
Fragments must be hosted by an activity and an activity can host one
or more fragments at a time. A simple fragment looks similar to an activity, but has different life
cycle callback methods.
One of the original goals of the fragment concept was to help developers make applications that provide different user experiences on phones and tablets.
The canonical example of fragment use is an email client. Let’s take a look at the Gmail app. When running on a phone, the Gmail app will display a list of the user’s emails. Tapping on one of these emails will transition the screen to showing the detail view for that particular email. This process is composed of two separate screens.
For your Question:
It is always better to use dialog fragment instead of Activity. Because fragments are more customizable and easy to use. Light weight and gives reusability.
You can know more here:
http://www.informit.com/articles/article.aspx?p=2126865
I am new to android programming and currently i am doing an app with with three tabs like this -
I followed this link to develop it.
But my current app calls separate XML files for each tabs. I want to call separate activity for each activity.
Please guide me with some materials or tutorials from basic.
I want to call seperate activity for each activity.
That is not supported. The old activities-in-tabs approach has been deprecated for over two years. You are welcome to use fragments or ordinary ViewGroups as the contents of your tabs.
Suppose current Activity called "A1" is running.
I want to start Activity "A2", but do not pause(call onPause()) and then resume "A1" when returning with back button.
Is there a way to achieve this?
What you're trying to achieve is not feasible. However, Android 3.0 has introduced the concept of Fragments. Fragment roughly speaking is a part of Activity layout with its own logic. By combining different Fragments you can create a multipart layout which will look like you have more than one Activity running at the same. Fragments are also supported in Android versions lower than 3.0 if using the Support Library. You can take advantage of Fragments concept in your application as it looks like this is the case. Hope this helps.
Just I have created graph chart using Chart Engine Android
I have used data from my database to use value for chart.
Now I have one activity which is main to display graph chart with left menu options.
So Whenever i am calling chart activity its going to show its own activity sepratly.
I want to embed that chart activity with my main activity with left menu options.
Is it possible? I am using android 4.0
How to solve this task? Please help me friends.
It sounds like your application would benefit from using Fragments The developer site has some very good information you should read.
You can't embed an Activity into another in Android, as Activities are meant to be independent objects.
Since android 3.0, you can use Fragments, which are Activities sub-elements, which you can combine in many different way. For example having your Activity using one left fragment to display a list of items and a right fragment to display the details of the selected item.
You should take a look at the Fragements documentation to implement this in your application.
Try Activity Group.
http://developer.android.com/reference/android/app/ActivityGroup.html