How to create or show scroll up - java

How do I create a button to scroll up
I see it in a lot of applications
I hope to get some help and also put some examples
Thank you

Depends on what you are using. You will need to give some extra info.
For a RecyclerView, to scroll to the top, you will do it like this:
recyclerView.getLayoutManager().scrollToPosition(0);
If you are using a ListView:
listView.setSelectionAfterHeaderView();

Related

What Box like view should I use?

I'm trying to create an app using Android Studio, and I want to use some type of expandable box, where I'll have an indefinite number shown like in a stack, and when clicking on the left side icon, the selected box opens up to show more info.
The basic idea of what I'm searching for:
Would anyone know about something like that??
Thanks in advance.
If I understand it well, what you're looking for is a recyclerview (for the indefinite number of row) and an accordion widget to open close your content.
I will suggest your to look at these projects:
https://github.com/hgDendi/ExpandableRecyclerView
https://android.jlelse.eu/get-expandable-recyclerview-in-a-simple-way-8946046b4573
which present all requirements you need.
And here is an similar question/answer : https://stackoverflow.com/a/10313432/6809926
The google search I made : android accordion recyclerview example.

Looking for a combobox but not an Android spinner

I'm trying to get the same item as Window's combobox in Android java. I realize there's a spinner but what I need is to display a scrollable list of items that the user can simply select one or more. The spinner is nice, but it's a totally different beast.
Is there an equivalent? Because otherwise I guess I would have to create a section of text items, that I would have to build my own scroll function as well as selection. Hoping to avoid all that.
Thanks.
You're going to have to write your own, or find a library. There is no builtin equivalent. Luckily it should be easy, you basically just want a recycler view where the adapter keeps track of what items you've clicked on. That will take care of the scrolling, and the display simplifies to a normal list adapter.
Import third-party library just for little feature is unnecessary, you could try change spinnerMode to dialog, then the spinner is scrollable.
Edited:
sorry, I noticed that you need select multiple items, my answer is not suitable. You could create a custom widget.
The easiest solution is using library. There a alot library you can use for that problem. Here is the some library you can used:
https://github.com/prsidhu/MultiSelectSpinner
https://github.com/pratikbutani/MultiSelectSpinner
Or you can follow this tutorial
https://trinitytuts.com/tips/multiselect-spinner-item-in-android/
Hope it help

Add views to the right or under depeneding on size of view

Basically, I have a bunch of custom TextViews and a set of data. I programatically inflate the textviews and set their texts according to my data. I want to add my views to the right of each other, and when there is no room horizontally, it will add a new row below. However, I am not sure what layout/view to use to achieve my goal.
Example of what I am trying to achieve:
enter image description here
Please Help!
I would use the Flexbox Layout library from Google. It does exactly this for you.

Gather parts from layout, java android

Im pretty new at programming android and this is my problem:
I have a layout page that i have alot of information on, including buttons and textedits. Now i want to split it up in different parts, without having to create different layouts for every headline. So for example, if i choose to see "Information 3" i want to hide everything else on the layout except the "information 3 text/buttons/textedits".
Is it possible to do this? Because i really dont have time for making a new layout for every headline, and i dont want to show every headline at the same time. (I want to keep all information/data in the same layout file)
Maybe there is a smarter way to do it? Thanks in advance!
/Erik
You can call view.setVisibility(View.GONE) if you want to remove it from the layout. you can search some more questions like these:
hide/show on click of Button
how-to-show-hide-grouped-views
Try these and if u need more help then let me know

Dynamic ListView Android (autodetecting the end)

I'd like to make a listview that, initially shows some elements of an array, loading more entries when you scroll down as maket does in example.
Can someone help me with or link solving that?
thanks
See https://github.com/johannilsson/android-pulltorefresh for one possible solution, and https://github.com/commonsguy/cwac-endless for another.

Categories

Resources