All Questions
2,346
questions
272
votes
14
answers
739k
views
How to create a drop-down list?
How can I create a drop-down list? I've tried a ScrollView but it's not exactly what I need.
237
votes
10
answers
118k
views
Android Endless List
How can I create a list where when you reach the end of the list I am notified so I can load more items?
168
votes
1
answer
301k
views
What is the difference between List and ArrayList? [duplicate]
I've been using ArrayList recently in my android project at the office and I'm a bit confused between List and ArrayList, what is the difference of the two and what should I use?
Also I saw some ...
129
votes
9
answers
209k
views
Call Activity method from adapter
Is it possible to call method that is defined in Activity from ListAdapter?
(I want to make a Button in list's row and when this button is clicked, it should perform the method, that is defined in ...
72
votes
2
answers
73k
views
Passing a List in as varargs [duplicate]
I have a List<Thing> and I would like to pass it to a method declared doIt(final Thing... things). Is there a way to do that?
The code looks something like this:
public doIt(final Thing... ...
61
votes
13
answers
222k
views
Print array without brackets and commas
I'm porting a Hangman game to Android and have met a few problems. The original Java program used the console, so now I have to somehow beautify the output so that it fits my Android layout.
How do I ...
59
votes
6
answers
109k
views
Change a value in mutable list in Kotlin
I got this mutablelist:
[Videos(id=4, yt_id=yRPUkDjwr1A, title=test4, likes=0, kat=pranks, ilike=false), Videos(id=3, yt_id=WkyUU9ZDUto, title=test3, likes=0, kat=pranks, ilike=false), Videos(id=2, ...
48
votes
4
answers
32k
views
Android Swipe on List
Does anyone have a simple example of a ListActivity displaying Textviews in a column and when you swipe left to right you see that row in a new view? This would be to say edit the data for that row ...
38
votes
3
answers
25k
views
Android Paging 3 - get list of data from PagingData<T> object
I'm using new jetpack Paging 3 library. I have one specific use case. I want to share this data between two screens using viewmodel.
One screen needs paged data and for the second screen I want simple ...
38
votes
5
answers
33k
views
How to set drawable size in layer-list
I'm having problem with setting size of drawable in layer-list. My XML looks like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@...
35
votes
5
answers
41k
views
How to flatten List of Lists in Kotlin?
I have a list of objects of class AA that contain a date and a list of objects of class BB:
data class AA(
val date: LocalDate,
val bb: List<BB>
)
@Parcelize
data class BB(
val x:...
34
votes
3
answers
17k
views
What is the equivalent of [NestedScrollView + RecyclerView] or [Nested RecyclerView (Recycler inside another recycler) in Jetpack compose
I want to create the following layout in Jetpack compose.
I've tried creating two lists inside a vertical scrollable Box but that's not possible as I got the this error:
"java.lang....
32
votes
8
answers
37k
views
Get uncommon elements from two list - KOTLIN
I have two list of same model class (STUDENT), sample student object structure is given below,
{
"_id": "5a66d78690429a1d897a91ed",
"division": "G",
"...
26
votes
2
answers
8k
views
Android loaders, the way to go?
I am used to building lists in android using adapters. If I need some long-to-get data, I use an asynctask, or a simple runnable, to update the data structure on which the adapter rely, and call ...
25
votes
2
answers
27k
views
Android listview with checkbox problem
I have a weird problem! I'm trying to create a listview with checkboxes. In my other thread I was told that I should use an array that keeps track of the rows that are checked. I did that and it ...
25
votes
2
answers
20k
views
Icons in a List dialog
I have been searching about ListDialogs . Whenever you can put the item you want with the :
builder.setItems(items, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface ...
24
votes
1
answer
78k
views
Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference [duplicate]
MainActivity.java has following code:
package com.softjourn.redmineclient.activities;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import ...
24
votes
5
answers
37k
views
Android - drag and drop - list rearrange
How can I create a list where I can rearrange list items with dragging
list rows to another row and so on (to change to order)?
Just like on the HTC Hero in the clocks app where you can rearrange
the ...
23
votes
2
answers
21k
views
How to reverse the order of list in Android?
I am developing in Android , I read the file from the folder and put into list.
The list has two value: 1.Name 2.Time
It can show the List like the following code:
for(int i=0;i<fileList.size()...
23
votes
3
answers
41k
views
looping through List android
I have the following method:
public List<String> getAllValue(){
List<String> list = new ArrayList<String>();
if(pref.getString(KEY_NUMBER1 , "").length()>2)
...
22
votes
3
answers
25k
views
Jetpack Compose LazyColumn Scroll Listener
I want to programmatically change which tab is selected as the user scrolls past each "see more" item in the list below. How would I best accomplish this?
21
votes
4
answers
39k
views
Android: How to disable list items on list creation
I'm pretty new to Android dev and still working out a lot of things.
I've got a main menu showing using the following code, but can't work out how to disable selected items in the menu. Can anybody ...
20
votes
1
answer
34k
views
Get list of installed android applications
Hi I want to get a list of all of the installed applications on the users device I have been googling for the longest time but can't find what i want this link was the closest though and works fine ...
20
votes
3
answers
24k
views
Store a List or Set in SharedPreferences
My app has a list of String values (of some 5-20 characters each), that I have to store persistently. The SharedPreferences seem to me the most appropriate, as it's a short list. Usually it will be ...
19
votes
8
answers
26k
views
Ordered lists inside an Android TextView
I want to display an ordered list inside a TextView, for example:
1) item 1
2) item 2
Using the following layout:
<TextView
android:text="<ol><li>item 1\n</li><li>...
18
votes
3
answers
27k
views
AutoCompleteTextView detect when selected entry from list edited by user
I have an AutoCompleteTextView I use to select an item from a long list. The user should only be able to select a predetermined item from the list. They should not be able to enter their own item.
...
18
votes
3
answers
33k
views
Kotlin - filtering a list of objects by comparing to a list of properties
I have a class Person:
class Person(var fullName: String, var nickname: String, var age: Int)
In my code, at some point I have a List of Person objects, and a list of nicknames.
var people: List<...
17
votes
6
answers
26k
views
How to clear cache Android
I need to find a way how to clear the data which my application stores in cache.Basically I am using Fedor's ( Lazy load of images in ListView ) lazy list implementation and I want to clear the cache ...
16
votes
3
answers
23k
views
How to sort a list of objects in kotlin?
I have a list of objects like this:
[
{
"Price": 2100000,
"Id": "5f53787e871ebc4bda455927"
},
{
"Price": 2089000,
"Id&...
16
votes
5
answers
75k
views
How to check all the running services in android?
I want to access and see how many and which services are running in background.
I want the exactly same functionality as we can access by
Menu->Setting->Applications->Running Services
on our ...
16
votes
5
answers
22k
views
Android custom list dialog
Hi,
I'm working on a simple file browser app. I have most of it set up (where it lists everything out in the different directories and what not) but what I'm stuck on right now (worked on it for a few ...
15
votes
1
answer
12k
views
Returning true and false in OnTouch?
Does it matter if i return true or false in onTouch() of an OnTouchListener?
I can't see any difference between returning true or false in this example: Android Swipe on List
15
votes
3
answers
82k
views
Android save List<String>
Is there anyway I can save a List variable to the Androids phone internal or external memory? I know I can save primitive data, yet not sure about this one.
Thanks in advance.
13
votes
1
answer
2k
views
Paging Library with custom DataSource not updating row on Room update
I have been implementing the new Paging Library with a RecyclerView with an app built on top of the Architecture Components.
The data to fill the list is obtained from the Room database. In fact, it ...
12
votes
6
answers
18k
views
Java convert ArrayList to string and back to ArrayList?
I wanted to save an ArrayList to SharedPreferences so I need to turn it into a string and back, this is what I am doing:
// Save to shared preferences
SharedPreferences sharedPref = this....
11
votes
4
answers
27k
views
Populate a list in Kotlin with a for loop
It's been a while that I just started to learn how to develop in Kotlin.
There is this thing that I am working on, I am trying to parse a list into another type of list. Basically they are the same ...
11
votes
4
answers
5k
views
Where to declare Kotlin extension functions in an Android app
Suppose I have the following code that I want to make as a re-usable component:
fun <T> MutableList<T>.swap(index1: Int, index2: Int) {
val tmp = this[index1] // 'this' corresponds to ...
11
votes
3
answers
13k
views
How do I pass a mutable list to a bundle?
I want to add a mutable list to a bundle, but there doesn't seem to be a way to accomplish this.
var bundle = Bundle()
bundle.put...????("LIST", fbModel.recipeArray)
You can use ...
11
votes
2
answers
5k
views
why use areItemsTheSame with areContentsTheSame at diffutil recyclerview?
why need to use areItemsTheSame with areContentsTheSame at diffutil recyclerview?
i don't understand i think areItemsTheSame is enough to compare data?
is possible more explain to me?
thank you
11
votes
4
answers
25k
views
What is the best way to fixed size of List in Kotlin
I have a list of ParentObject. Foreach parentObject, it has 2 childObject.
The image like that
val listParent: MutableList<ParentObject> = mutableList()
ParentObject {
ChildOjbect1{} ...
11
votes
1
answer
14k
views
android swipe to delete list row
so i've done some searching but haven't found a good answer. anyone who's familiar with android 4.0 knows the fancy swipe to remove running apps. i'm trying to implement this into a dynamic list.
...
11
votes
4
answers
7k
views
ListView with Alphabet on Android
I want to do a listview on android and it contains an alphabet near of the list (like iphone application).
I couldnt find any way to implement an list and having alphabets, when ı click on c letter ...
10
votes
8
answers
24k
views
Display new items at the top of a ListView
I'm using a list to populate a ListView (). The user is able to add items to the list. However, I need the items to be displayed at the top of the ListView. How do I insert an item at the beginning of ...
10
votes
6
answers
23k
views
Get filenames from a directory in Android
I want to populate a spinner with the filenames of files found on the SD card with specific extensions. I can get it thus far to populate the spinner with the correct files, but the path is shown as ...
10
votes
7
answers
91k
views
Flutter - The getter 'length' was called on null
I am trying to develop a flutter app. This flutter is creating teams for a card game. After the creation of the team, the points could be counted through the, so that you don't have to think about how ...
10
votes
1
answer
8k
views
Android: How to achieve the glow effect when long-pressing a list item?
With the default selector, long-pressing a list item causes its background to transition between two colors.
Replacing the selector with the one below removes the effect. According to this question, ...
9
votes
1
answer
20k
views
Sorting names in a list alphabetically?
Can you please help me for sorting a list alphabetically
My code
emailList.add(contact.getUserName());
String[] emails = new String[emailList.size()];
emailList....
9
votes
2
answers
26k
views
How do we remove elements from a MutableList in Kotlin
I have the following code where I need to display the elements of a list in view and then remove those items from the list. I have been looking into filter vs map in kotlin but no luck finding a ...
9
votes
1
answer
4k
views
Alphabatize list of installed apps
Hi I followed the below tutorial and successfully listed all of my installed apps in my application.
List all installed apps in style
However it does not list them alphabetically and i can not ...
9
votes
4
answers
37k
views
Square shaped layout border with round inside edges
I’m attempting to create a layout border with corners that are square on the outside and round on the inside. I’ve gathered that I need to create an .xml drawable definition composed of two shapes: ...