FAQ Database Discussion Community


Updating ListView On Custom ArrayAdapter

java,android,listview,android-listview,android-arrayadapter
I apologize if this is similar to other threads, but I have yet to find a good solution on how to update the ListView in my custom ArrayAdapter. I'm extending FragmentActivity in order to create a custom Dialog popup for adding / updating new List entries (which works fine), but...

List view setAdapter in fragment, null pointer exception

android,listview,android-fragments,android-arrayadapter
I ran into this null pointer exception at setAdapter for listView. Both the listView and the Adapter are NOT null. What's the issue here? OnCreateView of fragment @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View dataSearch = inflater.inflate(R.layout.fragment_datasearch,container,false); itemList = (ListView)dataSearch.findViewById(R.id.searchResults); // Item list is not null adapter...

Targeting a View within an ArrayAdapter in Android

java,android,android-activity,android-arrayadapter
I'm not certain if I'm asking this question correctly, because I can't find any information on it at all. I'd like to know if it's possible to target a view (ImageView) from my Activity that has been added through an ArrayAdapter. My Activity receives JSON from the server, regarding the...

getView in ArrayAdapter is not being called

android,android-arrayadapter
I've made my own ArrayAdapter but I'm having issues with the getView method - it's never being called. My Logcat is only showing the log from the constructor and never from getView. I've tried changing to a BaseAdapter and tried overriding getCount but with no luck, getView won't get called....

ArrayAdaptor constructor not being found

android,android-arrayadapter
I am working to display a list of all devices that have been connected to an Android phone. I would really like to keep using the fragments to help with easy navigation. I am getting an error on the ArrayAdapter adapter1 code that states Cannot resolve constructor 'ArrayAdapter(com.henryjarend.test.Connect2, int, java.util.List<java.lang.String>)'...

Sorting ArrayList with objects using Comparator and Custom ArrayAdapter

android,sorting,arraylist,android-arrayadapter,comparator
How do I sort properly ArrayList of objects using Comparator and then pass this sorted array to custom array adapter? I have tried like that: Content class of ArrayList: public class CoursesData { private String url; private String name; private String lessonsCount; private String isFree; private String price; private String...

How to change the rows color in Listview on specific data from Sqlite

android,listview,android-arrayadapter
I am showing all data/records of student in a single list view. Now at this point I am getting all data of students. I am getting student name,student roll number , address and their status (failed/Pass) 0 for fail and 1 for pass. I am getting it in a fine...

How to delete the complete view on click of delete button in android

android,android-layout,android-activity,android-listview,android-arrayadapter
I have made a custom view that contains an image,text and a delete button. I want to delete the the particular view when I click the delete button associated with it. Please tell how to implement this. Here is my MainActivity.java package com.khurana.nikhil.list1; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.LayoutInflater; import...

[Solved]Navigation drawer selected item textColor by Custom Adapter

android,android-arrayadapter,navigation-drawer,textcolor
May i know how to change the selected item's text color in navigation drawer. The android:textColor for listview is not working after install appcompat_v7 22.1.1 so i think i cannot change using selector drawable. I manage to change the default color of drawer items by using custom adapter. But this...

ListView shows wrong items on Scroll

android,listview,android-arrayadapter
I have a listview for displaying names. It shows wrong names if I scroll the screen. I understand that this is a common bug rooted in getView method of the adapter, however havent been able to solve it despite following the method presented in many existing discussions. I have pasted...

Android Custom ArrayAdapter Listview is not clickable with Async Task

android,android-fragments,android-listview,android-asynctask,android-arrayadapter
I have been stuck on this problem for almost a day now and have tried numerous previous posts on Stack Overflow, online tutorials etc. but nothing seems to work in my case. I have tried setting focusable, focusable in touch and clickable to false for all textviews in each row...

android listview ArrayAdapter string cannot be cast to HolderView

java,android,listview,android-listview,android-arrayadapter
In my application, listviews with custom arrayadapter crashes when scrolling the listview and the error is: 06-17 09:01:21.319: E/AndroidRuntime(32453): java.lang.ClassCastException: java.lang.String cannot be cast to SlideMenuListArrayAdapter$ViewHolder Note that slideMenuAdapter is my custom adapter, i bind it using arraylist of objects. this is the code of getView() @Override public View getView(int...

How to set parent background on ArrayAdapter

java,android,xml,android-arrayadapter
I am building an app and have some difficulties on setting backround on a array adapter, hope someone can help! public class ListAdapter extends ArrayAdapter { // List context private final Context context; // List values private final List<RssItem> items; public ListAdapter(Context context, List<RssItem> items) { // Set the layout...

NullPointerException with ListView and ArrayAdapter

android,xml,listview,android-arrayadapter,runtimeexception
when I select my btnPlaylist in my main.java I get the error code at the botton. I dont know what I'm doing wrong. It's saying I need to have a ListView with the R.id.list. I'm assuming it referring to my playlist_item_row.xml but I tried that and keep cleaning my project....

Edit row in listView, ArrayAdapter - Android

android,listview,row,android-arrayadapter
How can I change color of text in single row? Here is the code where I set adapter and call listView: ArrayAdapter<String> adapter = new ArrayAdapter<String>(getListView().getContext(), R.layout.row, rez); getListView().setAdapter(adapter); ...

Cursor Error in ArrayAdapter

android,android-arrayadapter,android-cursor
Hello I Need Help displaying palylists name,I Have recently changed from CursorAdapter to Array Adapter due to the error in getting the playlist ID,But now i need to know how to get the Playlist Name;I Use Cursor.GetColumnIndexOrThrow() but it's Returning an Error i dont know anything about: PlaylistFragment: public class...

List View Fragment Won't Display

android,listview,android-fragments,android-listview,android-arrayadapter
I am trying to display a list in my main activity using a ListFragment. The list is populated by my custom ArrayAdapter that uses a custom object. I am having trouble getting this list to show in the app. When I debug, it doesn't show any errors but the app...

Dynamic Custom ListView?

android,listview,arraylist,android-arrayadapter
I'm trying to make a dynamic Custom ListView, where a user can enter a name and age, an unknown amount of times. credit to @Razgriz he helped me get the Custom ListView working. I am now trying to make it dynamic. My issue is when I instantiate the NameAndAgeClass object...

Having a trouble with Asynchronous image loading in ListView

android,listview,parse.com,android-arrayadapter
this is very big trouble for me, I have been working for hours on this, and no clue ! I having a problem with Asynchronous image loading in ListView. I'm using Parse.com as my application's Backend, i'm retrieving Messages and their images from the Parse.com class. Everything is working fine,...

Android ArrayAdapter dynamic adding more data on scrolling

android,adapter,android-arrayadapter,autocompletetextview
I want to add some data at scrolling time whenever scroll reaches its 5 position but getting error ArrayOutOfBoundException... //Set adapter in MainActivity Context context = this; ArrayList<String> data = new ArrayList<String> ; for(int i =0; i <20;i++){ data.add("a"); } CustomAdapter customAdapter = new CustomAdapter( context, data); autoComplete.setAdapter(customAdapter); // Custom...

ListView not populating from ArrayList data

android,android-listview,android-arrayadapter
I am trying to populate my ListView with all Bluetooth devices that have been connected to the device. I went through a debug and the ArrayAdapter was receiving the data but not passing it through to the ListView My code is shown below Connect2.java public class Connect2 extends ListFragment {...

Set value for Spinner with custom Adapter in Android

android,dynamic,android-arrayadapter,android-spinner
I am developing a android application with spinner in a form. The spinner items and spinner values are different. I want to collect all the value from the from including spinner and set a rest api service to web back end. here is the response array. {"Status":true,"errorType":null,"countryList":[{"Code":"US","Name":"United States"},{"Code":"CA","Name":"Canada"},{"Code":"AU","Name":"Australia"},{"Code":"GB","Name":"United Kingdom"}]} I...

TextView in custom GridView adapter does not update, but ImageView does

android,arraylist,android-asynctask,android-arrayadapter,android-gridview
I have a custom GridView adapter that takes an AudioGridItem object as a parameter in its constructor. So basically each object has 2 ImageViews and 1 TextView. When I delete a grid position, using a long click listener, it should erase the file (on SD card) then put a placeholder...

NullPointerException on ArrayList in ArrayAdapter

android,nullpointerexception,android-arrayadapter
I have an array adapter for setting messages in a texting app. Upon either sending or receiving one message the app works fine. However, once a second message is sent or received, the app crashes and displays a NullPointerException error: java.lang.NullPointerException at com.example.feastapp.ChatBoxUi.DiscussArrayAdapter.getView(DiscussArrayAdapter.java:114) at android.widget.AbsListView.obtainView(AbsListView.java:2255) at android.widget.ListView.makeAndAddView(ListView.java:1790) at android.widget.ListView.fillUp(ListView.java:725) at...

Parsing JSON data and populating ListView

java,android,json,listview,android-arrayadapter
I am getting issue while parsing json Data and populating list view. For an example below is the json data i am trying to parse and the rest of sample code which shows what i am trying to achieve. [ { "id": 123, "name": "abcd", "department": { "name": "xyz", "code":...

Android ArrayAdapter does not update ListView

java,android,listview,android-arrayadapter
I have written a small implementation for a listview. Therefore I extended the ArrayAdapter class for my List rows and my objects. public class MainActivity extends Activity implements NetplugListener { public static final int REFRESH_ID = 1; ListView listView; ArrayList<NetPlug> netplugs; NetplugArrayAdapter adapter; RemoteDataManager remoteManager; @Override protected void onCreate(Bundle savedInstanceState)...

android: how to get and display data on an array list view

java,android,android-studio,android-arrayadapter
Am new to Android development using Android Studio. I am building an app that can create and view records. But on clicking create, it redirects me to the home page and when i click view, the app closes. This is the MainActivity for the Home Page with just two buttons,...

How to add condition in Android View getView (int position, View convertView, ViewGroup parent)

android,android-listview,android-arrayadapter
I have a Arraylist that contain a hashmap. hashmap contain a Topic name, Name and value. For example hashmap object like this.(I did not add the key for the example.) {"Topic A", "Name 1" , "100"} {"Topic A", "Name 2" , "100"} {"Topic A", "Name 3" , "100"} {"Topic A",...

Android - ToggleButton losses it's state after scrolling ListView

java,android,android-listview,android-arrayadapter,android-togglebutton
I have been trying from two days to solve this problem. I have seen many questions related to this problem. But they didn't work for me. I have a custom ListView. It's every row includes one ImageView, two TextViews and one ToggleButton. These all loads fine. When I change state...

SectionIndexer shifted in mock contacts app

android,scroll,android-arrayadapter,contacts,sectionindexer
EDIT: Solution at bottom of post. I am creating a contact screen for an android app where I want to be able to scroll through my phones contacts. I am able to import the phones contacts, use a custom arrayadapter to organize my information, and enable the fastscroll option for...

How to set size of colour in grid view and change it's shape to round

java,android,gridview,view,android-arrayadapter
package com.example.dhavalpatel.atira; import android.content.Intent; import android.graphics.Color; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.GridLayout; import android.widget.GridView; import android.widget.TableLayout; import android.widget.Toast; public class second extends ActionBarActivity...

Android ListView show different items than Adapter get

android,listview,android-arrayadapter
im trying to populate my ListView using my own custom Adapter. I'm trying to show 24 different elements from list, but what I get, are only seven elements from 0 to 6, which are displayed over and over again 24 (the number of all the items that display in the...

ArrayAdapter add method casting Illegal state exception

android,exception,android-arrayadapter
I have a problem adding items to my array adapter. Here is the code public void find_BondedDevices (View view) { // Look for bonded devices pairedDevices = btAdapter.getBondedDevices(); if (pairedDevices.size() > 0) { for (BluetoothDevice device : pairedDevices) { String deviceBTName = device.getName(); String deviceBTMajorClass = getBTMajorDeviceClass(device .getBluetoothClass() .getMajorDeviceClass()); pairedDevicesAdapter.add(deviceBTName...

List shows as not null but ArrayAdapter throws NullPointerException

java,android,android-listview,nullpointerexception,android-arrayadapter
Can anyone please help me? I just don't understand why does it throw null pointer exception. I work with ksoap2,WCF web methods and android. I checked the "list" in debugger mode and it is not null. Here is my code: public class MainActivity extends Activity { String loginMemberId = "a001";...

Hashmap Adapter doesn't like the Textview cast for displaying

android,hashmap,android-arrayadapter
So I was making a ArrayAdapter which takes a HashMap(String, Card) where Card is just a custom class of two strings basically to display information on a ListView later So I rewrite the getView method like: public View getView(int position, View changeView, ViewGroup parent) { final View result; if(changeView ==...

Extend a custom ArrayAdapter [duplicate]

java,android,android-arrayadapter
This question already has an answer here: Is List<Dog> a subclass of List<Animal>? Why aren't Java's generics implicitly polymorphic? 8 answers I have a custom ArrayAdapter that is used to place icons within lists public class IconArrayAdapter extends ArrayAdapter<IconListItem> { protected int resource; public IconArrayAdapter(Context context, int resource, ArrayList<IconListItem>...

Android: arrayAdapter throwing null pointer exception?

android,android-arrayadapter
I'm having some issues with an array adapter. this is what is in my lessonNotesList class: mydb = new DBHelper(this); //Creating an ArrayList of contacts data ArrayList array_list = mydb.getAllLessonNotes(); //Creating an Array Adapter to manipulate the contacts data into a ListView ArrayAdapter arrayAdapter = new ArrayAdapter(this,R.layout.list_layout, array_list); //Adding the...

Reverse List Order in Array Adapter

android,android-studio,android-arrayadapter
How do I modify this code so that it adds each new object to the top of the list instead of the bottom? I would like the latest object to be added to the very top of the list so you see older objects as you scroll lower down on...

Android, ListView showing identical data from ArrayList?

java,android,sqlite,arraylist,android-arrayadapter
The following code: int i = 0; for(Shift shift : mShifts){ shifts[i] = shift + ""; i++; } ArrayAdapter<String> adapter = new ArrayAdapter<String>(getListView().getContext(), android.R.layout.simple_list_item_1, shifts); setListAdapter(adapter); produces a list of all unique Shift objects - something that looks like... [email protected] [email protected] [email protected] [email protected] ... ect ... for as many Shift...

Unable to filter custom List View in android

java,android,listview,android-arrayadapter
I am new to android. I want search functionality to my custom ListView. I am working on project where I was trying to filter my listView using addOnTextChangedListener I saw online I didn't find anything helpful in my condition. here my code. EmployeeFragment.java public class EmployeeFragment extends Fragment { private...

ResolveInfo getIconResource() giving really strange results (incorrect icons)

java,android,arraylist,android-arrayadapter,android-package-managers
I'm creating a list of applications installed on the phone. I'm retrieving all installed application with the PackageManagerand ResolveInfo. Due to memory issue i'm using getIconResource() instead of loadIcon(). My question is how do i display the correct icons in an imageView using the iconResource, the int? EDIT: added code...

ListView text changing but not adapter data

android,listview,adapter,android-arrayadapter
I added 3 items to my ListView. Each item says "Test". When I click on an item, I clear that item's text. However, when I check the variable in the "watches" log, the item is still named "Test" even though I removed the text. watches log: adapter2.getItem(1) = {[email protected]}"Test" list.getItemAtPosition(1)...

Android: How to use List of String arrays inside List row

java,android,arrays,android-listview,android-arrayadapter
I am struggling with my custom listview. I want to populate my list view with my custom row.xml file which contains five textviews. I have a text file mytextfile.txt in the raw folder. It look like this: SUN-9-JULY-On Sale Now-New York, Time Square SAT-15-JULY-On Sale Now-London, National Gallery MON-23-JULY-On Sale...

onListItemClick doesnt work… Why?

android,android-arrayadapter
I try to teach me to make a list , with fragments . I have now created a custom array adapter to get my lines in the list to be adapted for my app . However , nothing happens when I press the item . However, working checkbox as intended...

Getting Memory leak on android fragment

android,gridview,android-fragments,memory-leaks,android-arrayadapter
I've been searching for a solution of the "memory leaks" problem on my android app, but, here is the thing: I'm loading a fragment inside a viewpager, this fragment have a Gridview and an Adapter (ArrayAdapter) which creates each item of the gridview, these items have an image and some...

Xamarin.Android: item previously inserted in ArrayAdapter is not found again

xamarin,monodroid,android-arrayadapter
I've inherited this Xamarin.Android app and it has a few issues. A particular bug involves an ArrayAdapter<ProductListObject>, where ProductListObject is a common POCO that's shared between subprojects (i.e. Android, Windows Phone and iOS); it just has a couple of properties (e.g. an Id) and overrides the (.NET) Equals() method to...

Override toString() method of final BluetoothDevice class

java,android,override,android-arrayadapter,tostring
In my Android app I have a ListActivity which displays bluetooth devices. I have an ArrayList<BluetoothDevice> and ArrayAdapter<BluetoothDevice>. Everything works but there is one problem. Each BluetoothDevice is displayed as a MAC address in the list but I need to display its name. As I know adapter calls toString method...

Update the ListView after renaming a ListView item within a Popup Menu in a BaseAdapter in Android

android,listview,android-listview,android-arrayadapter,popupmenu
I have a ListView which has a custom Adapter and a PopupMenu giving some options on the list item, including a rename option. After renaming the list item I want to refresh the ListView and display the renamed list item also. Following is my code. DocumentsFragment public class DocumentsFragment extends...

Android ListView Adapter not working correctly

java,android,listview,android-listview,android-arrayadapter
I've been attempting to upgrade an old app I made in college, including adding a listview to show data from Last.FM. The idea is having a main text with subtext under it, but the adapter I put together just isn't working. I've tried a good number of options, and the...

notifyDataSetChanged() from DialogFragment to GridView adapter in a fragment

android,android-fragments,callback,android-arrayadapter
I have a Main activity, that holds NavigationDrawerFragment (taken from android studio template) GridViewAdapter has OnLongClickListener, that runs SettingsFragment through the callback in Main: in Main: public void ShowSettings(Drink drink, int position) { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to...

NullPointerException in CustomArrayAdapter

java,android,nullpointerexception,android-arrayadapter
I'm trying to use a Custom Array Adapter to populate a ListView in in a Fragment. But I'm getting NullPointerException on method findViewById() in getView() method in Custom Array Adapter. Here is the CustomAdapter.java : package graph.prathya.com.materialdesign; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import...

ArrayAdapter unable to update contents

android,android-arrayadapter
I am trying to update the contents of my ArrayAdapter. I have tried calling the method notifyDataSetChanged() on the adapter and invalidate() on the ListView but I do not see the data within the adapter being changed. I spent two hours searching through every StackOverflow post about this topic, but...

Optimized way to use getView method in Adapter [duplicate]

android,android-listview,android-arrayadapter,listadapter
This question already has an answer here: findViewById vs View Holder Pattern in ListView adapter 3 answers I understand, calling every time view.findViewById(R.id.title); is much costly operation. How can i optimize this by storing these int values. What is the optimized way to use in List Adapter? @Override public...

How to separate ImageView from adapter of ListView

android,android-listview,android-arrayadapter
I have a listview with and adapter that changes the title (TextView) and an image (ImageView) of all single item. But I have a problem, I also have and inputsearch (edittext) with the function TextChangedListener to search any single item of the list view. But actualy this is mi code...

In Android how to prevent updating existing items on notifyDataSetChanged()

android,android-arrayadapter
I have chat app In custom array adapter. I set random colors to usernames for each message with this code: String[] array = context.getResources().getStringArray(R.array.username_colors); randomColor = array[new Random().nextInt(array.length)]; nameTextView.setTextColor(Color.parseColor(randomColor)); When new message arrive I add it to listview, and call adapter.notifyDataSetChanged(); This causes recoloring existing usernames in messages each time....

How to get Images from Internet and past it in a ListView?

android,json,android-listview,android-arrayadapter,listadapter
I'm doing my BlogApp. It gets all data from the Internet. I added three TextViews, but I have problem with getting images from JSON. I've tryed different ways but I still don't understand how exactly do this. Here is a part of my code: private void handleBlogResponse() { mProgressBar.setVisibility(View.INVISIBLE); if...

GridView.getItemAtPosition is always null (but list displays items)

java,android,gridview,android-arrayadapter,onitemclicklistener
I have a GridView object. It is showing photos from the users library. This is working and the list is scrollable on screen. However whenever I try to get the item that was clicked, I get null. _gridView.setAdapter(new ImageAdapter(getActivity())); _gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int...

Unable to find TextView when populating ListView with ArrayAdapter

java,android,android-arrayadapter,listadapter
I'm getting a nullpointer exception at the following line, as if the TextView I'm referring to cannot be found: descriptor.setText("Single"); I checked the ID field and it is exactly the same in the code and in the XML, I'm not sure if I have an error somewhere else in the...

Implement OnClickListener to the ListView Items

android,mysql,listview,android-arrayadapter,onclicklistener
I have sucessfully got the data from my server and displayed it in my ListView and now i want to implement Click event in the ListView Items. For now i am displaying the "id" and "SomeText" in my List view. My Question is How to implement a Click event in...

ListView crashes after scrolling

android,listview,adapter,android-arrayadapter
I implemented an endless scroll ListView, it works quite fine but after a "couple" of scroll, lets say 10, application crashes with this error java.lang.OutOfMemoryError at java.util.ArrayList.addAll(ArrayList.java:194) at android.widget.ArrayAdapter.addAll(ArrayAdapter.java:195) at com.bellantoni.chetta.lieme.ProfileFragment.onScroll(ProfileFragment.java:300) at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1755) at android.widget.AbsListView.trackMotionScroll(AbsListView.java:6554) at...

Adapter ListView not refreshing from Activity

android,listview,android-fragments,android-arrayadapter
I am trying to refresh the contents of my Fragment's ListView ... based on the results I receive in my Activity. What I want - To load contents of 'artistsName' List (present in my Activity) into the ListView of my Fragment What is the problem - Despite calling notifyDataSetChanged() on...

Set an item to the footer of listview

android,listview,android-arrayadapter,navigation-drawer
I have a navigation drawer which gets populated from strings and by using their position i am handling which activity to launch i just want listview last item should come at the footer of the listview. I used setFooter property but it is not working. What is the way to...

Generic Array Adapter for Alternate Row Color?

android,android-arrayadapter
I am trying to develop a Generic Array Adapter Class from which i like to inherit the row color property for odd and even rows. My Generic Adapter Class is public class SpecialAdapter<T> extends ArrayAdapter<T> { private int[] colors = new int[] { 0x30FF0000, 0x300000FF }; public SpecialAdapter(Context context, int...

while populating the Listview i am getting duplicates value in listview in android

android,listview,duplicates,android-arrayadapter
I have custom Listview.in which data is populates from array ,but I am getting duplicates value in listview while populating listview .please help ... the below is my code this is my Adapter class public class CustomUsersAdapter extends ArrayAdapter<User> { public CustomUsersAdapter(Context context, ArrayList<User> users) { super(context, 0, users); }...

Customise ArrayAdapter to fill GridView from bottom-left

java,android,gridview,android-arrayadapter
I've got a GridView I'm using for a wordsearch app which I'm populating which a String Array. However I want to populate it from the bottom left going across and then up instead of the default top left going down. I asked a question on here about it earlier and...

Android: Strong reference cycle using ArrayAdapter

android,android-listview,android-arrayadapter
In my attempt to abstract out common functionality for all the adapters in my application I come across something while looking through ArrayAdapter code that is bothering me. From what I know the common pattern of using ListView is like follow: Create ListView in XML which will have a reference...

Android simple ArrayAdapter from String[]

android,android-arrayadapter
i can write simple array adapter from class structure, but now i want to write simple array adapter from String, in my application i have simple array as : private String[] panelNumbers; panelNumbers = G.getActiveUserInfo().phoneNumbers.split(","); for show this array into Listview, array items merged with RadioButton, my xml layout: <?xml...

I am trying to fetch data from database and place it in a ListView in android

android,sqlite,listview,arraylist,android-arrayadapter
I want to create a quiz app which contains 1 question and 4options for that I created a database from which the questions and options are fetched to 5 textviews using ListView. I surfed many tutorials and using a page from stackoverflow created it using ArrayList and Cursor but i...

Spinner does not select item

android,android-fragments,android-studio,spinner,android-arrayadapter
I've been on this for a very long time and I can't get it to work... I have a spinner that is populated by a list of dates in my class that extends Fragment. However, when I select one of the dates from the dropdown spinner nothing happens. It should...

ArrayAdapter getView position is not true

java,android,listview,android-arrayadapter
For my ListView I have this ArrayAdapter ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, uas) { @Override public View getView(int position, View convertView, ViewGroup parent) { View item = super.getView(position, convertView, parent); if(uas.size() > 0 && tinydb.getInt("selectedUA", 0) == position) { item.setBackgroundColor(Color.GREEN); } return item; } }; Lets say the...

Check Checkbox getting from arrayadapter

java,android,listview,checkbox,android-arrayadapter
I have list of title-checkbox, and i want to have controll which one will be checked on default. So I'm trying to get the right view and check it, but for some reason it doesn't work. any idea why? form_checkbox_item.xml <?xml version="1.0" encoding="utf-8"?> android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" > <CheckBox android:id="@+id/checkBox1"...

How to update invisible/off-screen views?

java,android,android-arrayadapter,android-gridview
I've made a 15x15 GridView that contains 225 TextViews, numbered 0 to 224. I have access (via getChildAt(int position)) to all of the rows that fit on the screen at once, which is 180 TextViews or the first 12 rows. What I want to do is invoke a method (called...

Array adapter and listview issues after launching Intent Service

android,android-listview,android-arrayadapter
I have a list view being populated by my array adapter. Now everything works fine until i click on a row which launches an async task. My async task is supposed to download some image urls and launch an intent service in it's onPostExecute to download the images and store...

Android onItemLongClick adds position to the arrayList in different activity

android,listview,android-arrayadapter,onclicklistener,onitemlongclicklistener
I have got two activities. My goal is: After longClick on any ListView position in activity 2, I want some String to be added to ListView in activity 1. From activity 2 I'm going back to activity 1 by pressing back button. Each ListView has got different adapter. I tried...

Sorting adapter on particular array

android,listview,android-arrayadapter,baseadapter
I have a collection of object assigned to an adapter set to a listview. I know how to sort an adapter value when it contains single object. My question is how do I sort the collection only on the data datatype. Below is my collection you = new MyVideoAdapter(getActivity(),vDancers,video, vName,...

Dynamic Allocation of Array doesn't work for ArrayAdapter while assigning it for Spinner in Android

android,android-arrayadapter,android-spinner,dialogue
I am really facing a problem here to create a Spinner widget in Android. The goal is to populate a Spinner with data that i will dynamically retrieve from a source. Now I am able to create a spinner with a data source that is implicitly declared in the program....

IndexOutOfBoundsException issue with ArrayAdapter Class

android,android-listview,android-arrayadapter
I am trying to figure out why am I receiving the following error. java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.modup.adapter.WorkoutCardsAdapter.getItem(WorkoutCardsAdapter.java:75) at com.modup.fragment.CreateFragment$1.onPressed(CreateFragment.java:143) at com.modup.adapter.WorkoutCardsAdapter$1.onClick(WorkoutCardsAdapter.java:62) at...

Crash when switching from hard coded string array to getStringArray()

java,android,arrays,string,android-arrayadapter
I have a simple ArrayAdapter that is filled with a string array. ArrayAdapter<String> adapter = new ArrayAdapter<String>( inflater.getContext(), android.R.layout.simple_list_item_1, numbers_text); Everything works fine when I pass in a string like this. String[] numbers_text = new String[] { "one", "two", "three", "four" }; But when I declare the string this way,...

android - is array adapter compulsory to use?

android,android-listview,android-arrayadapter
Context : Android dev. Question : Is the use of an array adapter absolutely needed for performance/efficiency reasons ? Couldn't I use a for loop and add the views to the parent myself ? final View v = inflater.inflate(R.layout.first_fragment, container, false); LinearLayout sub = (LinearLayout) v.findViewById(R.id.add_me); LinearLayout vir = (LinearLayout)...

Using the ArrayAdapter class

android,android-layout,android-arrayadapter
Method-1: ArrayAdapter(Context context, int resource, T[] objects) Method-2: ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) I was using the array adapter class by passing values through method 2, and then I experimented a bit and passed values by method 1 and it still worked. I could not find a...

runtime error in customAdapter

java,android,listview,runtime-error,android-arrayadapter
I'm trying to create a list of Card view using a custom adapter. I have defined the layout of a single row of list, consisting a card view and imageview/textviews in it, in a separate .xml file. I'm using a custom srrsy adapter. My app crashes when I try to...

Populate Listview from a different function's ArrayAdapter - Android

android,listview,android-arrayadapter
This is my first post on stack exchange after a long while of creeping in the shadows ! I have a simple code, 2 classes: MainActivity: with a listview, an OnCreate method, and a custom method called Build List. other activity: Retrieves data online, then calls MainActivity's BuildList(String) method. The...

onListItemClick() not working on filtered search list in an ArrayAdapter (Android)

android,search,android-listview,android-arrayadapter,textwatcher
I have a list view on which I have implemented an onListItemClick(). It works well but when I filter the list using search, it opens wrong list items (sometimes ones not even seen in the filtered list). Below is my code, not sure what I am missing or doing wrongly....

How to know which of two adapters is being used in ListView onItemClick?

android,android-listview,android-arrayadapter
I have a ListView that is being populated (at different times) by two different custom ArrayAdapters (AdapterA and AdapterB). When a user clicks a ListView row I want to know which adapter is currently being used so that I can take the appropriate action and extract the data I need...

Android ListView ArrayAdapter getting data from host activity?

android,listview,android-arrayadapter
I have a custom ArrayAdapter which I use to populate a ListView in an Activity. The logic in the getView method of my ArrayAdapter requires an additional piece of information which is held in an instance variable in the host Activity. What's the best way of accessing this variable from...

ListView feeded with more adapters acording to need

java,android,listview,android-listview,android-arrayadapter
I'm pretty much new in Android coding. I have simple app where there is, amongst other views, a ListView. Now, when a 'bystanding' button is clicked, I need the ListView to change it's content... there are actualy three modes in which the ListView can be, now I was thinking how...

GridView items not displaying correct images or backgrounds

android,gridview,android-arrayadapter,android-gridview
I have a grid view which is being populated by a custom adapter (below). So I am passing an array list of object to the adapter, results of tests. The results of the tests are based on the variables in each object. So for example if object type is x...

Custom ArrayAdapter, listView, button

android,android-listview,android-arrayadapter
I try to capture the click of the button in MainActivity but this didn't work with me. How to do it. I put toast in my getView it seems to work, but how to catch the click in MainActivity. @Override public View getView(final int position, View convertView, ViewGroup parent){ LayoutInflater...

Android notifyDataSetChanged not working

android,listview,android-arrayadapter,notifydatasetchanged
I have an adapter which fills a ListView with 2 TextViews with data from a TreeMap. When the user adds or deletes Data from the ListView, the View should be refreshed. So here is my Adapter: public class MyAdapter extends BaseAdapter { private final ArrayList mData; public MyAdapter(Map<String, String> map)...

How to override getItem()?

android,android-arrayadapter,android-adapter
These are part of the code: public class Fruit { private String name; private int imageId; public Fruit(String name, int imageId) { this.name = name; this.imageId = imageId; } public String getName() { return name; } public int getImageId() { return imageId; } } public class FruitAdapter extends ArrayAdapter<Fruit> {...