i am using Listview inside the Scroll view. and this Listview is the last item of scroll view. Problem is when data gets load the scroller move down to the bottom. How can i prevent it from scrolling on loading data.
You shouldn't use a ListView inside a ScrollView as they are both scrollable.
However to solve your problem I guess you should use the attribute android:descendantFocusability="blocksDescendants" for your main container which resides in the ScrollView.
Related
I'm currently developing an app in android.
I have a really basic listview that has 3 elements in his adapter:
1 imageview and 2 textviews.
These 3 items are inside a constraint layout.
All i ask is if i can make this layout (imgview + 2 tview) scrollable horizontally.
I've tried adding the layout to a horizontalscrollview, it works but i can't take the list onclicklistener.
I assume you want to be able to click on a list item? You could try adding a click listener to the scrollView. You probably also need to set clickable = true on the scrollview (not sure which is the default) and also just in case set clickable = false to all 3 child elements so they don't "eat" the click instead of the scrollView.
Use RecyclerView instead, you can add the onClickListener inside the adapter itself, or if you want the clickListener to be more interactive between your adapter and your activity/fragment, you can try using interface inside the adapter.
I have a listView that contains my data, but instead of scrolling using the scroll bar, i need to be able to press a button to scroll up (if the listview can scroll up) and a button to scroll down (if the listview can scroll down)
Anyone know how i would go about this? I have checked the listView, and there seems to be no function to scroll up or down.
Ideally i would like to know if there are properties against a listView that tell me the
Maximum Y position that the listView can go to
Current Y postition that the listView is scrolled to
Using these values i can code the rest.
In the end, i removed the listView, and used a ScrollPane with a VBox. Then i added my items to the VBox instead. I had to make changes to the items i was adding to the listView originally, but this seems to work nicely.
I can now use the get/set property VMin, VMax and Vvalue on the scrollPane.
There is Flowless which acts as a simplified(*) (and more efficient) ListView. It has scrollX(dx) and scrollY(dy) methods that you can use to scroll the content.
(*) It does not support selection and inline editing out of the box, but can be implemented on top of it.
Below is a picture of my app, I am currently using a modified version of this app to show my expandable content. Now my problem is with my ImageView, I currently have 3 layouts, one for the main dialog (with listview), one for the listview title & arrow and one for the item details (item row once expanded). I want to add animation to the ImageView so when you click the image or title textview, the list will expand and animate the change. How can I do this? I cannot get the onClick to work because it doesn't know there are 2 imageviews, it seens only one...
I will assume that your ImageView is this arrow inside your ListView element (because you didn't write it clearly enough).
You probably shouldnt try to attach onClickListener to your ImageView at all (nor to your ListView element title). The good way of implementing what you want you achieve would be to use ListView's onItemClickListener to detect clicks performed on specific items inside your listview, and then expanding appropriate expandable content.
I have a page in my app where the user can see a news feed (mostly images). How do I display these images (Using a LinearLayout maybe?)? And if so, how do I dynamically increase the size of this scrollable layout as I am scrolling down? (To load more images)
You have to use ListView. From the doc:
A view that shows items in a vertically scrolling list.
you have to provide a ListAdapter to your ListView. Basically the apdater is what fills up the ListView. It is higly customizable. You can simply pass to the adapter your data set or extend the adapter and customize the getView method in order to get the data rapresentation you want.
a tutorial can be found here
Yes you have to use listview, just add the content and notify the adapter.
In my main layout (mainlayout) I am displaying some text and images which are set dynamically based on the actions of the user. For one particular button click I need to display the contents of another layout (secondlayout). I do this using:
setContentView(R.layout.secondlayout);
On the second layout I have another button that I use to return to the main layout, once again using:
setContentView(R.layout.mainlayout);
The problem is on displaying the mainlayout again all the text and images I was displaying have now disappeared.
How can I return to the mainlayout and still display the contents I was displaying?
don't do it that way. setContentView() is meant to be called once in your onCreate() method. however, couple of reasonable ways to do it,
encapsulate each layout in a fragment, then show / hide each fragment as needed.
bundle both layouts into a single layout, and show / hide each section of the layout by calling setVisibility() on the layout's outermost container.