ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down to the bottom of the page for a screen shot.
The component is a Library Project. This means that there's no need to copy-paste resources into your own project, simply add the viewflow component as a reference to any project.
<org.taptwo.android.widget.ViewFlow
android:id="@+id/viewflow"
app:sidebuffer="5"
/>
The use of app:sidebuffer
is optional. It defines the number of Views to buffer on each side of the currently shown View. The default sidebuffer is 3, making up a grand total of 7 (3 * 2 + 1) Views loaded at a time (at max).
To be able to use the more convenient app:title
the application namespace must be included in the same manner as the android namespace is. Please refer to the layout main.xml in the example project for a full example. Again, note that it's the application namespace and not the viewflow namespace that must be referred like xmlns:app="http://schemas.android.com/apk/res/your.application.package.here"
.
ViewFlow viewFlow = (ViewFlow) findViewById(R.id.viewflow);
viewFlow.setAdapter(myAdapter);
If you need to listen to screen change events you would want to implement your own ViewFlow.ViewSwitchListener
and pass it to the setOnViewSwitchListener()
method.
viewFlow.setOnViewSwitchListener(new ViewSwitchListener() {
public void onSwitched(View v) {
// Your code here
}
});
- Marc Reichelt, http://marcreichelt.blogspot.com/
Copyright (c) 2011 Patrik Åkerfeldt
Licensed under the Apache License, Version 2.0