FAQ Database Discussion Community


Notify RecyclerView adapter database changed

android,database,android-fragments,android-adapter,recyclerview
My MainActivity calls a fragment, @Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.container, PlaceholderFragment.newInstance(position + 1), "placeHolderFragmentTag") .commit(); } placeholderFragment that fills a RecyclerView with an adapter, public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment();...

Android textview adapter is not returning id of particular textview find with tag

java,android,textview,adapter,android-adapter
I am learning android development and working on a small game app. So here is my code which is working, LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View gridViewContent = layoutInflater.inflate(R.layout.game_grid_view_content, null); final TextView tv = (TextView) gridViewContent.findViewById(R.id.g_v_content); tv.setHeight((gridViewHeight/8)+5); tv.setTag(position + 501); tv.setId(position + 1001); tv.setText(String.valueOf(...

Android listview adapter with buttons in getView that change the layout

android,listview,android-adapter,baseadapter
I have a listview with a few buttons that I want to disclose more information. I have an xml file for the layout with several nested LinearLayouts. When the "Comments" button is pressed I want the appropriate layout to appear and then disappear. Inside of the model object I keep...

Dynamic measure text in a a custom listview item, OnGlobalLayoutListener only called once

android,listview,android-listview,android-adapter
I am showing a ListView in my app with a custom item. The custom item is already doing quite a bit of work since I am using the android-swipelistview from 47deg found here. So the "front" part of the list item is a LinearLayout with various bits nested inside it...

Accessing imageview inside adapter on OnItemClickListener

android,android-adapter,onitemclicklistener
My navigation drawer consists of many items. Each item has background image(with id optionbackground) which is invisible. I want to make the image visible only when user clicked on the item. How can i do it? ImageView whose visiblity I want to change is named optionBackground in Adapter. And my...

Activity with Listview does not show the items

android,android-layout,listview,android-listview,android-adapter
I have the activity "VerSolicitudesPendientesActivity.java" which load when i select one item of main´s menu. This activity contains a listview which does not shows the list, but yes the TextView. This is the activity: public class VerSolicitudesPendientesActivity extends Activity { /* (non-Javadoc) * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle...

No adapter attached; skipping layout

android,android-adapter,recyclerview,android-cardview
logcat error : No adapter attached; skipping layout I changed the context argument with getActivity(), but the app is still not running. public class FragmentActivity extends Fragment { private RecyclerView mRecyclerView; private CountryAdapter mAdapter; private LinearLayoutManager layoutManager; public FragmentActivity(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View...

How to sort a listview in alphabetical order ANDROID

java,android,sorting,android-listview,android-adapter
I've been following this tutorial here on how to make my own Android launcher. I can currently display all the installed apps on my phone in a listview. How can I edit this code so that the list is in alphabetical order? protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_apps_list); loadApps();...

ListView Filter filters correctly but shows wrong result

java,android,android-listview,android-adapter,searchview
I have a custom Adapter that I use to display custom objects in a ListView. Furthermore, I used a SearchView that allows me search through the ListView and filter out results. However, I have noticed some strange behavior when I try to enter a search. As long as I search...

Android runOnUiThread crash when pressing Back button

android,asynchronous,nullpointerexception,android-ui,android-adapter
I am using the DownloadManager to download files from a server, I'm doing it from an adapter, and I'm showing the download progress in the fragment using a runOnUiThread. it's working great, but when I press the back button while downloading, the runOnUiThread throws a NullPointerException. I tried putting a...

What action triggers onItemSelected in a ListView?

java,android,listview,android-adapter
I have a ListView of Medications that use a CursorAdapter. My goal is to obtain a reference to the Cursor of the selected item when the user presses the submit button, but I keep getting a null value. Here is my current code: mSubmitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View...

I have error when use context in adapter, i would like use startActivityForResult(…) in adapter, how should I do?

android,android-intent,android-activity,android-adapter,android-context
and thank you in advance for your suggestions. MainActivity.java RecyclerView.Adapter mAdapter; @Override ... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); mAdapter = new MyAdapter(getBaseContext(),TITLES,ICONS,NAME,EMAIL,PROFILE); mRecyclerView.setAdapter(mAdapter); mLayoutManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mLayoutManager); ...} @Override protected...

Activtiy1 to Adaper to Activity2 ,and how to use the Activity1 data in Activtiy2

android,android-activity,android-adapter
I have two Activies, named Activtiy1 and Activity2, and one Adapter. Activity1 use the adapter, and in the adapter, I use intent to jump to Activiy2. My problem is that Activity2 wants to use the data from Activiy1, but I have no simple way to come through. I want a...

Android: Change listview layout when searching adapter?

android,android-listview,android-adapter
I have a listview with adapter, when searching the listview for NON existing item I want to display a layout for adding new one, I want to display it inside the listview to make it easy for the user and not moving to another window or popup dialog. When the...

Android: On click in adapter give wrong position

android,android-listview,listener,android-adapter,android-adapterview
I am developing an application in which i am having a list view with custom adapter. I am attaching the ArrayList to the custom adapter. The adapter is having four image view, and onclick listener is applied to each image view in get view. I am populating the array list...

failed to call Adapter method from fragment

java,android,listview,android-fragments,android-adapter
I am using fragments with tabs. I have two fragments: AddTask.java and AddedTask.java I have one Adaper class Adapter.java public class Adapter extends BaseAdapter { Context context; List<Reminder_Database> lists; TextView title, date,time,note,date_edit,time_edit; EditText title_edit,note_edit; AddedTask addedTask; int ids; public Adapter(Context context, List<Reminder_Database> list, AddedTask addedTask) { // TODO Auto-generated constructor...

Best way to provide custom view for selected list item

android,android-adapter,android-adapterview
Goal : have completely custom layout for selected item, considering only single item can be selected at a time. I do not want to involve getViewTypeCount/getItemViewType for selection as they are already used in this adapter for different purposes. One obvious option is inflating custom layout to indicate selected item...

retrieve values of NumberPicker in listview (custom adapter)

android,android-listview,android-adapter,numberpicker
I have an activity that get data (arraylist) from a previous activity and put it in a listview through a custom adapter. In this custom adapter i declare a textview (to show the data) and add a numberpicker for each row. I want the user to be able to select...

Custom Adapter with ListView

android,android-layout,android-listview,android-adapter
I am trying to utilize a custom ListView library that I found on Github that pins headers of a section. That library works fine however I am now trying to implement my own custom Adapter so that the pinned headers have a different layout from the other list items. I...

Displaying the same image files in adapter - Android

android,android-adapter,android-gridview,android-file
Situation: I have an activity that contains an image picker function to select images. Once selected, these images are loaded/displayed in a GridView. I load the images using ImageLoader library with the following method: ImageLoader.getInstance().displayImage("file://"+image.path, Utility.displayImageOptions); In the same activity i have a Preview button which clicked lead to an...

Android - asynctask that fills an adapter for a listview

android,android-listview,android-asynctask,android-adapter,swiperefreshlayout
Basically the flow is like the following: when a fragment is created (or when the user swipes to refresh the layout), an AsyncTask is executed. The ASyncTask retrieves the info from a URL and setup an adapter which is then assigned to a ListView. This is the code of the...

Getting android Sqlite syntax error running in api 14

android,android-activity,android-sqlite,android-adapter,simplecursoradapter
I have sequence of database adapter, which dumps default values in to the tables. It works fine on the devices running on API level 19 to 21. When I tried it in API 14. I'm getting the syntax error. I/SqliteDatabaseCpp﹕ sqlite returned: error code = 1, msg = near ",":...

Dynamically change the number of columns of a GridLayoutManager

android,gridview,android-adapter,android-gridlayout
I am actually using a GridLayoutManager with two columns in my app and I would like to have one column depending on the view type used. Here is the code I have in the method "onCreateView()" of my fragment : // Recycler view for users usersList = (RecyclerView) mView.findViewById(R.id.usersList); //...

Custom Adapter throws nullpointerexception with no reason

java,android,android-listview,android-adapter
I have this custom adapter and I don´t know why throws exception if views are in layout inflated. I then use the adapter un a new class to show listview. What is null? import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import...

notifyDataSetChanged() doesn't work with my custom adapter

android,android-fragments,android-adapter,android-recyclerview
I've created a simple RecyclerView.Adapter and it displays the content properly, but when I call notifyDataSetChanged() on it - it doesn't work. PastEventFragment public class PastEventFragment extends Fragment { private RecyclerView mRecyclerView; private List<PastEventItem> mPastEventItemList; private PastEventAdapter mPastEventAdapter; public PastEventFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...

Can I set custom onClick on my timeline using fabric sdk?

twitter,android-listview,onclick,android-adapter,fabric-twitter
I am creating a Twitter client using Fabric but I can not create a custom onClick. I created this custom adapter and tried to create a OnClickListener but not working. Always open in browser tweet. public class TweetAdapter extends TweetTimelineListAdapter { public ArrayList<Long> tweetIds=new ArrayList<Long>(); public TweetAdapter(Context context, Timeline<Tweet> timeline)...

App crashing on some random devices

android,android-fragments,android-listview,android-adapter,android-navigation
Today I encountered a Strange Problem in my app. SO in first activity, there is a navigation drawer with some items listed in listview (in drawer).there is scrollbar in navigation drawer. now, on some random devices Problems occurs. App is launching correctly but as soon as I scroll ( Inside...

GridView, Get Item's parent View

android,android-layout,android-view,android-adapter,android-gridview
I'm trying to send clicks to my child elements in GridView with a single touch event. So far, I can retrieve the data of the child element, but cannot perform a click on it. Let me explain a bit more on the layout of things... GridView - Touch Event Handler...

Android adapter populated by Retrofit callback

android,android-adapter,retrofit
I have a Navigation Drawer which has an adapter to populate a ListView with some data. I'm using Retrofit to make an API call to get the data, and utilizing the callback methodology. However, I'm getting an error within the adapter when the getCount method is called because the callback...

Spinner in ListView(android)

java,android,android-listview,android-adapter
I apologize for my English. I have a lot of time can not figure out how to make a spinner in ListView. I do not understand how to add items to the spinner, and then inserted into the spinner ListView. The following attempts to do something similar, please see me...

Loading image from URL in custom adapter for ListView (Android Studio)

android,image,url,android-listview,android-adapter
While the bitmap seems to be fetched right, the variable 'userBitmap' will remain null. When scrolling up or down on my tablet, though, new list rows will contain the pictures, but they're all the same and wrong. Really, really confused. I've tried a number of different methods getting an image...

Android Persistent ListView recycling

java,android,android-listview,android-adapter
I have been fighting with this problem for days. Looking for the solution on stackoverflow or anywhere a solution is given, tried all of them even tried recyclerView but nothing helped. My PROBLEM is that I've a listview and two textView on a listItem. So whenever I click on list...

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> {...

How to update an imageView source onPostResult of async task in BaseAdapter class

android,android-layout,android-adapter,android-adapterview
I want to update an image view source after downloading in OnPostExecute method in async method Here is getView method of my base adapter class public View getView(int position, View convertView, ViewGroup parent) { vi = convertView; ViewHolder holder; if(convertView==null){ /****** Inflate tabitem.xml file for each row ( Defined below...

ListView with custom adapter: some items are hidden

android,android-layout,android-listview,android-adapter
I have a ListView with a custom adapter, but when scroll in ListView some items are hidden: From the image you can see that from a69 jumps to a72 leaving hidden items a70 and a71. Here is the code of the custom adapter: public NewCurrenciesAdapter(ArrayList<NewCurrencyData> list, Context context) { m_list...

Why elements adding at the end of ListView?

android,android-layout,android-listview,android-adapter
I am working with custom ListView. Why items were added to the end of list view? I have only 3 items. 15000.00 is added first (so it is not reversed). ...

Loading image in onCreate doesn't fill adapter correctly

android,storage,android-adapter
My application is able to take pictures and to save and to show them in a list. They also can be deleted and the list is correctly updated. However, if I close the application and then launch it again, the list is no more correct. In detail: These are the...

Best way to save a arraylist

java,android,arraylist,sharedpreferences,android-adapter
This question has been answered before, but the solutions doesn't seem to work for me. I would like to know what the best way is to save an ArrayList. I generate an ArrayList with all the installed applications on the phone. This list is shown in a ListView where the...

Changing a business object in an Adapter

android,json,android-adapter
I'm building an android app similar to Facebook (gets a newsfeed stored in db from a REST API), and I am now implementing a reddit-like voting system, in which every feed item has a vote state (none, up, down) stored in db. When I do retrieve the newsfeed json, i...

ClassCastException when using adapter with two view types

android,android-adapter
I am trying to use two types of views and two types of ViewHolders in my adapter, but I see the following error: java.lang.ClassCastException: com.Sleep.Adapters.FriendsListAdapterFromKesh$ViewHolder2 cannot be cast to com.Sleep.Adapters.FriendsListAdapterFromKesh$ViewHolder1 at com.Sleep.Adapters.FriendsListAdapterFromKesh.getView(FriendsListAdapterFromKesh.java:226) at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220) at android.widget.AbsListView.obtainView(AbsListView.java:2186) at...

RecyclerView.Adapter custom filter exception

android,android-adapter,android-recyclerview
I have a custom RecyclerView.Adapter class where I implemented a Filterable and used the interface method override like so: private MyFilter myFilter = new MyFilter(); // Class implemented below and also implemented the: @Override public Filter getFilter() { return myFilter; } This is MyFilter class implementation: public class MyFilter extends...

Dynamically Increase the text count on click in BaseAdapter

android,listview,android-listview,android-adapter
I have Like Button In Layout and set the text "like 0" , i Have Set in Base Adapter , When I click on Like Buttton, the text will increase without refresh the whole Activity Like in facebook app , I am stuck on three days , i have read...

How to choose adapter for view pager?

android,image,android-viewpager,android-adapter
I need to show images in ViewPager. But I don't know which adapter to choose: 1) PagerAdapter 2) Fragment Adapter. What is better for my task to display images?...

Best way to update data with a RecyclerView adapter

android,android-adapter,recyclerview
When I have to use a classic adapter with a listView I update my data in the listView like that: myAdapter.swapArray(data); public swapArray(List<Data> data){ clear(); addAll(data); notifyDataSetChanged(); } I would like to know what is the best practice for a RecyclerView. Because in a recyclerView adapter you can't do a...

findViewById returns null when try to find TextView in getView [on hold]

android,android-layout,listview,android-adapter
I don't know but findBtView method cannot fint view and get null all the time. Here are my files: http://pastebin.com/0gJPH8mi

ListView updated from EditText

android,android-adapter,custom-lists
I have a Custom Listview that it is updated from a EditText component in a dialog. I have the custom row, the adapter class and the custom dialog all working but I can't seem to trigger the code in the adatper class that would add the text from the edit...

Efficiently Inflating a lot of Views within several Horizontal LinearLayout with Adapters

android,performance,android-layout,android-linearlayout,android-adapter
I have a question about how to improve the performance of a large horizontal linear layout. I am creating a table like view that can have anywhere from 50 to 2,500 entries. Each entry is a LinearLayout containing a TextView with some simple text. I have implemented the design by...

Having difficulty controlling webview from other activities/classes

java,android,android-webview,android-adapter,recyclerview
As it stands right now, In my app I am writing, I have a navigation drawer via NavigationDrawerFragment with a RecyclerView populated via an adapter in another class, and a WebView in my MainActivity. I'm at a point where I've got click handling from my RecyclerView's adapter and what I...

NullPointerException for adapter.notifyDataSetChanged?

android,android-adapter,android-recyclerview
I have a RecyclerView that get me crash in adapter.notifyDataSetChanged(); : public class ListContent extends Activity { String _comment; public ArrayAdapter adapter; RecyclerView recList; Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listcontent); recList = (RecyclerView) findViewById(R.id.cardList); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL);...

ListView Adapter executing onclick methods on multiple rows simultaneously for a single click event

android,listview,android-listview,android-adapter
In my app I have a listview in a tab fragment. Each row of listview is a cardview , which has multiple views in it.(Buttons, textviews etc.) I have created a custom adapter class for this listview. This adapter class takes the data from local DB and inserts it in...

Refreshing listview duplicates content

android,listview,android-adapter
I have a listview which populated with arraylist. However, anytime I use the pull to refresh, the data in the listview gets duplication even though I clear the arraylist before populating. This is my arraylist List<TimeItems> myList = new ArrayList<TimeItems>(); and this is how I am populating the adapter for...

Correct way and location to initialise adapter

java,android,android-activity,android-adapter,android-listfragment
I'm trying to setup a filter for my list view but I've come across these errors. Cannot resolve symbol 'myAdapter' I know that myAdapter hasn't been initialised, but I don't know which of my classes I need to declare it in. error: method setOnQueryTextListener in class SearchView cannot be applied...

Is making network call safe in ArrayAdapter?

java,android,android-adapter,retrofit
I have developed AutoCompleteTextView with Google Places API. When the user enters address, I'm making network call to API. I tried to simulate crash, but the request completes before I'm able to change the configuration. public class PlacesAutoCompleteAdapter extends ArrayAdapter<Prediction> implements Filterable { private List<Prediction> resultList; public PlacesAutoCompleteAdapter(Context context, int...

Android GridView getChildAt(0).findViewById() returns null

android,android-adapter,android-gridview,baseadapter
I have a GridView with some items, I used a custom adapter that extends BaseAdapter. each row shows a downloadable item, each row has an icon that show download progress. So I need to update this icon. For this update, I know that I can change the data and call...

Why return false in Java?

java,android,android-studio,android-adapter
I'm writing an Android app that uses an AdapterView. There are multiple calls to IsInFilterMode() in the AdapterView class which simply is a one line function that returns false. I can't override the function so I can't for the life of me figure out why this function exists if it...

Android WebView in a ViewSwitcher loadUrl loads once

android-webview,android-adapter
I have in my ViewSwitcher a ListView and a WebView. In my ListView's adapter, I have an onclick listener that writes the clicked url in the list to sharedpreferences. I'm trying to load that url into the WebView using an onSharedPreferencesChangedListener. This is the code in my adapter: convertView.setOnClickListener(new View.OnClickListener()...

How to set data to custom row TextView in ListView

android,android-listview,android-adapter
I want to show data which i get from server, in my custom ListView This is my row_category.xml for custom row <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageView android:id="@+id/imageView1" android:layout_width="80dp" android:layout_height="80dp" android:layout_marginLeft="10dp" android:layout_marginTop="5dp"...

listview onitemclicklistener with layoutinflater

android,android-activity,android-listview,android-adapter,android-inflate
I want to open a new Activity when the list items are clicked, I was used a CustomAdapter class for displaying list items with the help of Layoutinfaltor. Here is my code Exercise.class public class Excercise extends Activity { public String taskName[] = { "Table Tennis", "Basketball", "Badminton", "Swimming", "Gymnastic",...

Getting different integer value from resource folder in Android

android,android-adapter,android-resources
I have a listView in my screen. I want its adapter populate 3 items if the device is small screen (320*480) while 4 items for the rest. The way I'm doing that in adapter: public class MyAdapter extends BindableArrayAdapter<SOMETHING> { private static int MAX_DISPLAYED_ITEMS; public MyAdapter(Context context) { super(context); MyAdapter.MAX_DISPLAYED_ITEMS...

Keep current scroll position when update listview

android,android-listview,android-adapter,onscrolllistener
I want to get new data and update it into my listView using the code below, What i want is when i scroll until the bottom of the listView, it will automatically update and add new data into the list. E.g: like facebook, only add new data to the bottom...

Choose Android.R.layout when setup GridView in android

android,android-layout,android-gridview,android-adapter
I am currently working on a grid view. Since the grid view item is only a textview, I have not create a custom layout. But when I tried to use simple_list_item_1, I found that the item click area is just the size of the text, not the whole item....

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification - List with Universal Image Loader

android,listview,android-asynctask,android-adapter,universal-image-loader
I am trying to update a fragment with list view once the Async call is complete but I am getting the following error : java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. I am updating the adapter onPostExecute and have also checked the...

Adding a footer view in RECYCLER VIEW?

android,android-adapter,recyclerview,android-recyclerview,recycler-adapter
i want to add a footer layout at the base of the recycler view.Below is my adapter view which inflates header layout as well as other items as well.Help appreciated! public class SplitMembersAdapter extends RecyclerViewAdapter<SplitMember, SplitMemberViewHolder> { private final ArrayList<SplitMember> mSplitMembersList; private final ImageLoader mImageLoader; private static final int TYPE_HEADER...

No data inside the custom adapter

android,android-adapter,android-viewholder,android-recyclerview
This code is from slidenerd tutorial for recyclerview im trying to bind the data to the recyclerview using getdata function public static List<Information> getData() { List<Information> menuData=new ArrayList<>(); int[] icons={R.drawable.ic_bluetooth,R.drawable.ic_crosshairs_gps,R.drawable.ic_laptop,R.drawable.ic_remote}; String[] titles={"Bluetooth","GPS","Laptop","Remote"}; for(int i=0;i<titles.length&&i<icons.length;i++) { Information current =new Information(); current.iconID=icons[i];...