As per screen 1, I have one Title view, and a listview below it,
I want to place a 'hidden view' above this 'title view' which will be visible only when I have scrolled this list till the top.
I have seen Hide your actionbar
and QuickReturnListView and ObservableScrollView
but as I understand none of them serves my purpose. Do anybody know how to achieve something like this?
You made one of the awesome question. I will just suggest creating one custom layout which will get added into the header of the ListView, and that custom layout contains these two views one is always 'visible' and other view in default 'gone' mode and while the time of refresh makes it 'visible'. or you can use addHeader method while on start and end refresh.
listView.addHeaderView(headerView);
I hope this suggestion will work, "Best of Luck...!!"
"Happy Coding...!!!"
Related
is there a way in android to make it so that an item or title type item sits at the top of the view of a list view? I want a section title to sit at the top of the visible part of the list view until the next one comes to the top and replaces it.
Check out the PinnedHeaderListView and the android-amazing-listview projects. They both provider ListViews with pinned header capabilities.
I suggest you use this library PinnedHeaderListView
github.com/mldeng/PinnedHeaderListView
This will definetely help you achieve exactly what you want.
I am trying to create something like (very poorly created in paint) in the image below:
I have only 4 items, and it won't be more. the items contains two textviews. But when you click on an item, i want it to expand, (like item 2) to the bottom with three extra buttons. It would be really nice if there would be some nice expand animation. I don't want this list to be scrollabe, it just need to fits in my screen. And only one can be expanded.
I think there are two options, but maybe i am missing something.
1) Create an itemlayout.xml, containing an linearlayout or something containing the extra buttons, set to linearlayoutbuttoncontainer.setvisibility(View.GONE). And then build a switch, which closes the others than the clicked one, and set the visibility of the clicked item to visible. This would be fairly easy to build i guess, i don't foresee a lot of problems. But is it possible creating an animation or is there only a sudden screen change?
2) expandable listview, with the buttons in the expandable item. I know its possible to make only one item expanded, by rembering the expanded one and closing it again. But is it possible to make it like this, with the buttons in the expandable part? Actually i've never used an expandable view.
Anyone know what the best solution should be?
Thanks
I would recommend using an expandable list view for this, as your second option described. For this type of list you can use a expandable listview adapter, describded here:
http://developer.android.com/reference/android/widget/ExpandableListAdapter.html
This adapter has both a getGroupView(open/close items) and a getChildView method in which you can inflate your layouts, or manually set them up. If you have used ordinary listviews I'm sure this wont be a problem for you, since it's basically the same operations.
This means you should probably inflate your childViews with a LinearLayout containing three buttons. Then you have to implement functionality for your collapse/expand logics by keeping track of which item index is opened.
I did this tutorial when I first started out with exp.list views, I found it helpful:
http://android-adda.blogspot.se/2011/06/custom-expandable-listview.html
Good luck!
You gotta check this http://udinic.wordpress.com/2011/09/03/expanding-listview-items/ it works neat. If you got any more problems, do ask...
I want to display a recursive or nested text view at depth of 3 in Android.The text to be displayed is, dynamic coming from web service.
for example:
If I Click on Help(Level 1)
it'll show topics under Help
If I Click on Help_Topic_1(Level 2)
it'll show questions under Help_Topic_1
If I click on this question, say HT_Question_1(Level 3)
it'll show Answer of that question(Level 3)
how to accomplish with this? please guide me.
You should use ExpandableListView. Reference http://developer.android.com/reference/android/widget/ExpandableListView.html
You can call expandGroup and collapseGroup methods for expanding and collapsing on clicks.
the simplest way to do this is to have a nested layout structure. Your root view will contain the button to show level 1 and a child layout and initially be visible. The children's layout visibility will initially be set to "GONE". In the onclick listener for each button you change the visibility of the layout below it to view to "VISIBLE".
This of course is a very simple way of doing it. If you require to have open and close animations you'll need to use a more complex method.
I am using AdapterView to have Custom List. But my Xml layout not only
contains that List. It also have some other elements like TextBox,
labels, ImageButton at the top and bottom. so when i scroll it up
and animation starts it also draw elements on that Top Part(Which
contains ImageButton and other stuff). so can some one tell me how can
i remove it ? another issue is it do not have scrool bar. can some one
tell me how can i add scroll bar in it ?
for adding scroll bar to the listView add this attribute to your listview in the xml
android:scrollbars="vertical"
Check the following link. here i mentioned a complete code to use listview properly. Using this we can achieve any listview behavior. We can embed animation also.
For controlling list View Behavior ensure the getView Method of your list is generating the vew dynamically and as per your requirements . Each time a list get scrolled . The getView Method get called for all the element in the view. Do account all these things.
Change ListView background - strange behaviour
Hope this help :)
I'm having abit of an issue and i'm not too sure how to go about solving it.
Essentially i have an activity which has a base xml layout of ScrollView and i want this activity to list some results from a Cursor. So i thought i'd use SimpleCursorAdapter... however when i got it all set up it appears that the ListView that the SimpleCursorAdapter goes into doesn't play nice being within another scrollable layout element.
I've sorta got it working programmically but i'd much rather use a ListAdapter as it will make each list entry look like a button and keep it inline with the design of the rest of the application and can handle the ids of each item and where to send the user upon clicking.
So my question is this: is there anyway to either make ListView show all the items such that it never needs to scroll, or can i change the ListView to something like a LinearLayout?
I hope that makes sense!
Any help / insight / ideas are welcome!
Cheers!
You can NEVER use a scroll view and a ListView together. Its a mess! and illogical as well.
Here are some of the approaches you can use:
Theres no screen big enough to show all the content of you listView you can try wrapping up your content but as I said it won't help as scroll view and list view don't work together. So you can either remove your or
If your list items are simple you can dynamically add your views to LinearLayout with specified location
Another tip I can give you is you can always use an relative layout and place your listView alignParentBottom="true" and emit the scrollView approach this will make you listview alwyas scrollable.
It doesn't really make sense to have a ListView inside a ScrollView at all. The ListView implements it's own scroll function so it should not be used in conjunction with a ScrollView anyway.
You should rethink your UI design.
I agree with Shardul; trying to put a listview with a scrollview will make it impossible to scroll. Have a look at the links below to see what you can accomplish with just a ListView -
a.
custom backgrounds info.
custom adapters