I have an Android app with two classes:
-MainActivity
-SecondActivity
I have also two layouts for these classes (they are pretty similar).
I want to switch between these activities by 'shifting' to the right or to the left.
All materials I find are about switching by button.
Anyone would recommend using Fragments and ViewPager instead of Activity since you want sliding action and make use of the Android TabLayout.
Here is a tutorial that you can draw a basic idea from.
Related
I want to make something like this in my android app
With 2 or 3 activities or more. I don't want to use visible tabs with names. I just want when i slide through a new activity with its own layout appear, a totally different screen. I've read about viewpager and pageradapter, but i' m a little confused. What do you think is the best way to do it?
This is what you need, just follow this tutorial http://www.androidhive.info/2015/09/android-material-design-working-with-tabs/
You dont even need multiples activities.
You can actually create a swiping activity in android studio.
Goto:
File -> New -> Activity -> Tabbed Activity and choose Navigation Style to be Swipe Views.
Android Studio will do the rest. Then you can change the fragments according to your need.
EDIT:
This is a nice example that demonstrate using Activity with ViewPager.
Android PagerView between Activities
I am trying to practice different functionalities in Android using Android Studio.
Right now I wish to make it so I can swipe left/right between various components.
A good example of this is the app called Simple Workout Log. The top bar is scrollable (in a more localized way) whereas the bottom of the screen scrolls over entirely with each swipe.
I did notice something called HorizontalScrollView in Android Studio but couldn't figure out how to mimic the functionality.
How is something like this made?
Create tabbed activity and it will automatically implement view pager and FragmentPagerAdapter for you.
After that you can look up for tutorials on creating tabs using frgments such as this one
I've been working on a school project in a course for Mobile prototype for a couple of weeks when our mentor said we should change our way of navigate in the app.
Before the app started with a simple menu where the user could chose which feature to open, which could be different activities, listactivities, mapactivities, activities with custom views, ect.
We then found the ActionBarSherlock library which could help us make a nice tab bar. But should we then change our activities to be fragments (supportfragments runs 2.3.3) or can we keep it as (normal) activities? if so how to best show this under each tab.
Actionbarsherlock have been implemented successfully in our apps start activity and now we "only" need to make the navigation to the existing the activities or change them to fragments.
Do tell if this isn't clear what have described or you need any further information.
If you wish you can only use Activities with ActionBarSherlock
It all depends on what your want to achieve and the use of fragment might help you making a cleaner app.
Actionbarsherlock sample:
1° tab bar with fragment & viewpager
2° tab bar with fragment
I'm developing an application and I want to place two activities in a tabbed layout. I need the ability for the first activity to send an intent and programmatically switch to the second tabbed activity. This seems possible and is outlined in other posts:
Launching activities within a tab in Android
However, this approach doesn't seem advisable and it makes use of ActivityGroup, which is now deprecated. Can anyone recommend a stable solution that would meet my design needs?
You may want to take a look at ViewPager from the support library, coupled with https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/library/src/com/viewpagerindicator/TabPageIndicator.java
It will produce a tab-like interface that you can swipe through. You can explicitly change which tab is being shown by calling viewPager.setCurrentItem(int).
Can I implement a tab host which will remain in overall application and works through out the application .
and
Also can i implement the tab host on the top and on the bottom of the same activity.
Any tutorial any help please....
Thanks
This is possible if you use Activity Group. But still it is deprecated and hence you cannot use it for newer versions of android. But still, you can go through what it is and try to implement it.
ActivityGroup Example
http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/
http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity
So now since Activity Groups are deprecated what is the alternate strategy we can make use of? Here is the solution for this problem.
Go for fragments or Views.
I have pasted the comment which I recieved from Commonsware regarding the ActivityGroup.
You never needed ActivityGroup to use tabs. You can put views in tabs, for example (github.com/commonsguy/cw-android/tree/master/Fancy/Tab). Going forward, tabs are in the action bar on Honeycomb, typically using fragments. You can achieve the same functionality on previous versions of Android using ActionBarSherlock.