Hi i've just implemented a horizontal scroll for my android application,according to some excellent sample code that i received from here my only problem is that I'm swipping through TextViews what I actually wanna do is swipe through activities.As you will see through the link i provided the TextViews are defined in the .xml file from the horizontalpager so scrolling through them is done quite automatically.How can i achieve the same results but this time with activities?
Activities arent Views so no way and no good idea anyway!
But what you wanna do can be done with a ViewPager and Fragments!
Fragments:
http://developer.android.com/guide/components/fragments.html
ViewPager:
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
Edit: Here would be the Adapter you would wanna use:
http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
Hi i came accross to an excellent blog explaining very explicitly the above and also providing some sample code so i'll post it just in case any one stumbles upon the same problem as me, note: that's a link for quick downloading of the sample
Related
I am beginner. I am looking for Tutorials of Swipe / Refresh / Listview with adapter which Data comes from Parser.com. I can't find in the web the suitable one!
I tried a lot of one but nothing work well.
Can you advice where can I get one is working well and easy to understand?
I work with Fragments, I don't know if it is correct way to work with theses fragment to create ListView?
Your help will be appreciated!
Regards,
Marwan
I'm typing here because I can't comment.
I learned how to use list view from
https://www.youtube.com/watch?v=BSZLqBWKTHw
and
http://developer.android.com/guide/topics/ui/layout/listview.html
As for using fragments, You can put them in fragments. I would do that if the fragment would be used in more than one activity or if you want make use of space in larger screens.
I have a complex ListView involved layout in my Android project that looks something like the picture attached. The layout has a top, fixed part (the meeting details) with TextViews Join, Edit and Delete that are clickable (really listen to onTouch events), with Edit and Delete only showing up for the meeting owner/creator.
There is, however, the ListView part below the fixed part as well, and this part has a number of unknown comments, presumably posted by people who have been invited to the meeting. Anyone whose account has access to this meeting, and who sees this layout can comment on this meeting information layout. However, only comments created by a person have the links Edit or Delete (again, onTouch listeners on those TextViews). In this way, think of this page as the detail page when you click on post in Facebook and you see all the comments posted, but are only able to edit/delete your own comments.
I thought I could set out with a solution like this page, with the top, fixed part and the ListView in the same fragment layout, but that will only work if I have the same links for all the comments. That is not the case for me, because the links Edit and Delete for each comment will only show up if the comment is by the comment author.
How should I do this? Do I have to write my own Adapter? Is that the only way? How would I go about writing my own Adapter? Any pointers/tutorials/links appreciated.
Lastly, I was wondering how I can set listeners for each clickable item on the comments. I know I have to use setTag() and getTag(), but don't know where to do this.
Any help is deeply appreciated.
Vogella.com has some good android tutorials. Here is one for writing a custom adapter. The android docs also have a tutorial on listviews, but it doesn't look like they tell you how to do custom adapters. They do, however, tell you how to handle clicks on the list view.
You can setup your comment view to display the Edit and Delete buttons or not in the getView() method of your BaseAdapter class.
I know it may be weird that I want to succeed.
Let me explain whole in details. Firstly, I want to use two ListView looking in an Activity screen. Just like how Pinterest looks like. (I'm not sure is it true but it's named as heterogeneous gridview.) There is also one thing that I needed to implement: lazy loading. There are about 30 images in my activity, so that's not good to fetch all images at one time. That's why I needed lazy load.
So in first, I pondered on that I how obtain that appearance, I mean heterogeneous gridview. Then decided to add to LinearLayout in a ScrollView. Linears have vertical orientation. With thay approach, I added my new views by using odd-even method in Linear Layouts.
Althought, there weren't any adapter so according to my knowledge, there is no way to controll which items would be displayed. So lazy load is not suitable.
I've also tried two ListView in an Activity, but got some lag and also synchronous scroll problems. On the other hand it has a bad recycling.
So in this scenario, I want to ask is there way to fill LinearLayouts using Adapter? Or what would you recommend to create a heterogeneous gridview but also with lazy load.
If my approaches are wrong, I would not hasitate to change it.
Any clue would be great for me. If there is something unclear, please specify it. I'll explain with more details.
After a lot of research, finally I found a library which have lazy loading and heterogeneous gridview and also not has any scroll or recycling lags/problems.
Maurycy's StaggeredGridView is completely what I'm looking for.
Here is the library and also there is a demo too.
If I get your question right, here is what you need: http://spinlist.autsia.com/
I am making an android app where I have listview being populated using fedor's Lazy Loading solution. This happens after I do some work in an async task and on completion of which my listview gets populated. The listview contains an ImageView and a TextView for every single row. I want to use the ViewPager implementation where on one page, I have the listview and on selection of an item in the listview, the user gets shifted to another page on the right (or maybe he can swipe to another page) where he can get the detail screen of the ListView Item. How is this possible. Do i need to use ViewPager or some implemenation of Tabs. Also if someone can refer me to some good tutorial related to ViewPager and How to implement Activities inside viewpager, that would be great!
Thanks in advance!
If you looking for the swipe than you should use GestureListener interface...
you can find this at following link
I had recently done the swiping of ListViews using viewPager it works very well
Follow this tutorial
http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-horizontal-view-paging/
You can read this from android developer site also for better understanding http://developer.android.com/training/animation/screen-slide.html
Please feel free to ask any doubts I had done this recently
Use Fragments within View Pager(not activities)
Use ViewPager if it is a listView and some other screen for the swipe.
for detail view on selection of list item, use a separate fragment and load it in the container.
Just:
Set a background that support the selected state in your list item layout, like:
android:background="?android:attr/activatedBackgroundIndicator"
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
FYI: http://cyrilmottier.com/2011/08/08/listview-tips-tricks-3-create-fancy-listviews/ and http://android-developers.blogspot.mx/2008/12/touch-mode.html
I'd like to create a gallery of photos that swipe left and right. At first I took a look at Gallery, but it's marked as deprecated.
http://developer.android.com/reference/android/widget/Gallery.html
We're told to try ViewPager instead. But the PagerAdapter class doesn't handle recycling of views for us (like a standard ListView), does it?
http://developer.android.com/reference/android/support/v4/view/PagerAdapter.html
Is it up to us to build the recycling mechanism?
Thanks
But the PagerAdapter class doesn't handle recycling of views for us
(like a standard ListView), does it?
No, and I think it's because it was built assuming you are using different layouts for each of the page.
Also, as it is not being scrolled as fast as a ListView (you cannot "fling" a ViewPager to skip multiple pages), I think it doesn't need to have to recycle.
This HorizontalListView is great, i used it to do exactly what you want.
see the link in the edit on this question The link in the Edit, and the answers give you some possible ways to solve.
There is also a HorizontalListView online somewhere if you search for it that makes a fine replacement for Gallery and does recycle its views.