Scrollable PagerTabStrip - java

I've been searching for this topic for a while, and can't find enough resources or tuts about scrolling a PagerTabStrip. I'm using the FragmentStatePagerAdapter and populates the PagerTabStrip with getPageTitle(int position). I'd like to know how to make the titles scrollable. I'd like to scroll the titles without affecting the view by the time I stop or select into a specific title, then that's the time the view gets updated. I've been thinking to use HorizontialListView but not sure how to start. Hoping to learn from you. Thanks.
Found this on docu:
PagerTabStrip is an interactive indicator of the current, next, and
previous pages of a ViewPager. It is intended to be used as a child
view of a ViewPager widget in your XML layout. Add it as a child of a
ViewPager in your layout file and set its android:layout_gravity to
TOP or BOTTOM to pin it to the top or bottom of the ViewPager. The
title from each page is supplied by the method getPageTitle(int) in
the adapter supplied to the ViewPager.

I been searching on this on the web, but I didn't get any relevant resources. I just found out another library called actionsherlock that enables the scrolling of tabs without affecting the view which is exactly what I need, instead of using PagerTabStrip's listener .

I'm also searching for the same thing. Too bad you have to make your own implementation or use third-party library. I have read that this library offer the feature of scrolling tab independent of the content. But I have not tried it out yet.
http://viewpagerindicator.com/?utm_source=androidweekly&utm_medium=toolbox
Do you actually mean the ActionBarSherlock? Do you have an example?

Related

execute class from included layout

Within my layout I have set a Include Other Layout. this layout schould in his turn show a listview with items loaded from the web (my webserver)
the only problem is: the items don't load in because the class that holds the code to load the items isnt called on because im using a Include Other Layout meaning only the layout is called and not the functional code from any .java files (classes)
leaving me with a blank page...
is there a way to make a call upon the class containing the code for the layout i have included?
<include/> tag is only for including only the view into another layout. It can be very useful if you use a common view everywhere. A ProgressBar can be an example. You can include ProgressBar everywhere you want. But it is just a UI.
If you also want the functionality you should use Fragments. Actually Fragments are exactly for what you describe.
Here is the tutorial from Android Developers official website
http://developer.android.com/training/basics/fragments/index.html

Android Horizontal Scrolling that Snaps to List Items

I'd like to implement a UI experience in Android where a user can view a single item (for example, an item in my case is a collection of texts), and swipe left or right on the item to go to the previous or next item.
From my research, ListView does not implement horizontal scrolling. Potential candidates seem to be HorizontalScrollView and GridView, but I haven't seen any examples that can do this simply - only seemingly complicated libraries that need to be included.
My question is, is there a way to use ListView, HorizontalScrollView, GridView, or a combination of them to implement a horizontal scroll that shows one item at a time and snaps to the item being displayed?
The highlighted area in the picture below shows where I'm trying to implement this logic.
It looks like the best option to achieve this experience is a ViewPager, which requires the android support library.
http://developer.android.com/reference/android/support/v4/view/ViewPager.html

Fragment Z-order changes when orientation changes

My main xml file has a FrameLayout, with one fragment defined in the XML. At runtime, I am adding another fragment on top of this, and then a third fragment on top of this. When I add the runtime fragments, I don't give containerIds to attach them to. This is all fine until the orientation changes. After the orientation change, the third fragment has gone beneath the second fragment. But obviously I want the z-order to stay how it was before the orientation change, i.e. the last fragment added should be on top and visible.
I've tried using containerIds when adding the fragments, and adding them to the FrameLayout defined in XML, but when I put in containerIds, the runtime fragments simply don't show up at all.
So I'm wondering why the fragments added at runtime don't show when I use a containerId. Is it because they are being added to a container which already contains a fragment (the one defined in XML)? How can I get around this? I've tried adding additional containers to the XML to hold the runtime fragments, but this doesn't seem to work. The only way to get the fragments to show is to remove the containerId from the call to FragmentTransaction.add().
Also, is it possible to change the z-order of fragments manually? I've searched Google quite a lot to find this out and haven't found any answers. I've tried using ViewGroup.bringChildToFront() and using the view returned by the fragment's getView() but this hasn't worked. I've also found out that you can nest fragments on Android 4.2+ with getChildFragmentManager(), but I'm supporting older APIs, and this method doesn't seem to be in the support library.
Any help greatly appreciated!
The way I got around this was to manually recreate the third fragment after the orientation change, and remove the one created by the system.

How can i change the List XML via a swipe gesture

at the moment i'm trying to write an app which has a listview, and if i swipe especially left the listitem switches to another xml like it's used in the twitter app.
Especially i have a list of items only with some text and when i swipe left on a single item it changes to an other item (via a xml-file) especially with some buttons or anything else.
I hope anyone, has an idea how i can do this?
Thanks.
I have seen this done using a Gallery set to fill_parent. Care has to be taken to allow child views to pass on touch events appropriately for swiping to work. Note that Gallery is a subclass of ViewGroup.
EDIT: see comment below, i should've checked the twitter app first!

Android Update Layout Content

I'm looking for a way to update a layout's content with a new view. Is there any way to easily do this. It would be similar to how tabs work, but I don't want to have to get into extending the current tab structure if I don't have to.
The final result would be a few buttons that would switch the content in a specific linearlayout for each button.
Any help?
Have a look at ViewSwitcher. This is designed to help with the kind of things you are suggesting.
If you want the contents in entirely different layout files, you can use a LayoutInflater and add the inflated view to the parent view.

Categories

Resources