I have existed code for two activities(ActivityA and ActivityB).
Now I need to have a another activity, which will act as my first and only screen of my application. This activity will be having two tabs on its header part and I need to display each of my Activity when user press on each tab.
I have done some search on this and found TabAcivity will be suitable choice, but it is deprecated now.
I saw many posts which are suggesting Fragments. But I dont want to change my existing code. Can any one suggest me easy method to incorporate this.
you can use Android Tab Layout with Swipeable Views
here i give Link in this link step by step information given. so i think you can get batter idea from that.
Tab Layout with Swipeable Views
you can also download code from this site and also see video in given sit
Related
I often put user registration on one xml file with scroll view.
I have learned when a user sees too many fields they opt out of the app so I am planning to upgrade the layout to look like the one for gmail when you sign up on android app. It appears to be using tabbed view but not tabs available and user navigates to the next view by clicking next (refer to attached images).
First page
second page
MY QUESTION
My question is how do I create this views, do I need many xml layout files or put all stuff on one file and use visibility as in once it is filled and user presses next hide the inputs and reveal the next inputs. Note: Gmail appears to be scrolling to another page the way it would appear when using tabs.
You can use one activity to host multiple fragments. The new Android Studio update has Navigation Editor which you can use to achieve similar results.
it is totally up to you how you want to design this but the best thing is you use Fragment and viewpager instead of using two separate layouts.
See Here how to use fragment with viewpager
There are many ways to do this, If you have less content then play with visibility otherwise ViewFipper ( https://abhiandroid.com/ui/viewflipper ) Or can use Fragments
I am making my first android application with the ActionBarSherlock.
The application will always have an action bar consisting of 3 tabs (first tab selected by default).
The app could be extended for use with a tablet.
I have been searching the web, and following the android development guides, however I am finding a few things confusing.
The first tab screen will be a list view with a list of items, onitemselected should send the user to a screen which features more details about that item.
When should I use a fragment? Should each tab be a fragment?
Or, should each tab call a new activity, which consists of fragments?
And, if using fragments, should I place them in different classes, or embed them within an activity??
Appreciate any help, thanks.
you should probably read these two links first.
http://android-developers.blogspot.com/2011/09/preparing-for-handsets.html
http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html
If you plan to make an app that work on both phone and tablet. It is a good idea to use a fragment, and then use a shell activity to wrap that fragment.
My experience with Fragments is mostly on ViewPager, so I am not entirely sure if it applies here.
In Android, you should use Fragments as much as possible. As a general rule of thumb, imagine you are translating the UI from phones to tablets, elements that can stay together in the same configuration should be a Fragment.
There is a Fragment subclass called ListFragment, so you might want to look into that for your first tab. (ListFragment is for Fragment like ListActivity is for Activity)
There is also a tutorial I found to deal with fragments. Did not really look into it but I hope it helps.
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
As for ActionBar / ActionBarSherlock, I have absolutely no experience withit so someone might want to add to that.
After scanning all the related questions regarding multiple activities under one tab, I found out that they all refer to using ActivityGroup which is deprecated.
Basically I have 2 tabs, the first one contains a main activity with several buttons and when button is clicked 1 for instance a new activity should open under the same tab, clicking back should bring me to the main view under the first tab. The second tab contains only one activity.
Tried inflating a new view for the sub-activities:
FrameLayout frameLayout = tabHost.getTabContentView();
frameLayout.removeAllViews();
View view = getLayoutInflater().inflate(layoutID, tabHost, false);
frameLayout.addView(view);
But I only get the view, I cannot handle it like an activity; meaning adding buttons or listeners, it's only a view.
Google suggests using fragments instead, but I am having the hard time implementing this. Maybe replacing the activities with fragments could be the solution.
I could really use a good tab\fragments example right about now...
Any suggestions? Thanks in advance.
Yes, the solution to your problem is using Android Fragments.
I understand that you have trouble figuring out what to do. It's everybody's difficulty actually. However, with enough patience to google out things, you will realize it's actually not that difficult.
What I will be telling is basically some tips on how to change your code to fragments. From your current code, there's actually a major change you need to do but it's worth it.
What you are doing is actually you're making a dynamic UI. You have chunks of fragments which eventually can have different listeners which you should later on defined. Here's a sample demo you can actually wok on.
If you want a detailed tutorial, I followed this one. And, yes, it works!
Have fun learning Android and don't forget Android is directly linked to Google. And you can easily google things and ask specific questions here should that question was never asked before.
I have a tab layout, inside which I am successfully able to lead an Activity.
However, I would want such a mechanism so that I can have few buttons in the bottom, and when the user clicks them, I am able to load different Activities inside the same Tab.
This functionality may closely resemble having Tabs inside a Tab, which, I feel, isn't a good practice and will make the things quite unpredictable.
how to do something like this?
What you want to do can be achieved by using Activity Groups.........
Search for some samples........
I am providing two links, check if it helps you............
Link1
Link2
In my application I want to use 4 tabs and each tab will have more than one screen. So I tried to get this and found there are two ways to do this:
Use ViewFlipper inside every tab.
Use ActivityGroup in tabs.
However, I'm not sure which will be efficient and easy way to do this since I'm a newbie in Android. So please help me.
Please post me some link where I can get sample code related to ActivityGroup.
Activities are self-contained parts of your app, views are used together when they display similar type of data/behavior.
For example if your tab 1 is taking a picture and your tab 2 is showing a map and your tab 3 is sending an email then you're better of using activities as the action are completely different, with different layouts and different behaviors.
If tab 1 is a listview with an rss feed from techcrunch, tab 2 is a rss feed from StackOverFlow and tab 3 is a rss feed from bbc news then use a viewflippers : Same behavior, same actions
THis is simple to implement
Adding Activity Group will be more preffered then adding View Flipper. By this all the code and activity contents are separated and in more manageable form plus its a stable thing to use
I have the same issue but got it totaly RESOLVED Check The Following Link
http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html
Changing the view within the Android Tab Widget
Its The Solution For Me . Hope It will Help You as Well