FAQ Database Discussion Community


ListView with extended Base Adapter is not updating properly

android,listview,baseadapter
I am currently writing a custom BaseAdapter for a ListView on Android. The List Adapter basically works fine when I first insert items in the ListView, but upon inserting new Items in the middle, the wrong items are displayed after calling notifyDataSetChanged(); Here is a simplified example (ive stripped it...

Baseadapter with ViewHolder, crashes on Scroll

android,listview,baseadapter,android-viewholder
i am using a listview with baseadapter and on scroll of the listview it crashes. My getView method of the BaseAdapter class @Override public View getView(final int arg0, View arg1, ViewGroup arg2) { // TODO Auto-generated method stub LayoutInflater inflater = activity.getLayoutInflater(); ViewHolder holder=null; if(arg1 == null){ //Login category if(categoryList.get(arg0).getType()==1){...

How to limit an array list to 10 and display next 10 items on click of more

android,arraylist,baseadapter
I am adding all the items in arrayList, now I want to display only 10 items in my recycler view and click of more 10 more and so on. I want to use same arrayList.

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

Android application using GridView and BaseAdapter

java,android,gridview,baseadapter
I am trying to run the Android App on my emulator/device. There is no compile time error , but the app crashes when run on the device/emulator and "Unfortunately, GridViewMapExample has stopped" message id displayed on the screen. MainActivity.java package com.example.gridviewmapexample; import java.util.ArrayList; import android.support.v7.app.ActionBarActivity; import android.content.Context; import android.content.Intent; import...

removeAllViews in HorizontalScrollView does not remove views

android,baseadapter,horizontalscrollview
I am getting few crashes because of this code: (I never got a crash on my devices) The crash is:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first Here is the code (I added a try and catch to make sure that...

Android Custom Adapter - Won't return view?

android,listview,fragment,baseadapter,custom-adapter
I'm having a problem with returning my view to a listview with my custom adapter. This is what I have in my main class which extends Fragment. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_perfil_config, container, false); ListAdapter adapter = new PerfilOptionsAdapter(listOptions(), getActivity()); listPerfilConfigOptions =...

Unable to populate custom listView using BaseAdapter in Android

android,android-listview,baseadapter,layout-inflater
I am new to Android. I am creating custom listView using BaseAdapter. I try this code,but my app get crashed. I don't know where I made mistake? AreaFragment public class AreaFragment extends Fragment{ private ListView list; private Context c; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View...

Adapter Subscribing to Multiple Observables

android,android-sqlite,baseadapter,rx-java,sqlbrite
My question is What is the best way for an Adapter to subscribe to multiple observables I have an Adapter that has a header and regular item types. The information for the adapter is fed from a database using Sqlbrite. Using Sqlbrite, I want to update the header and the...

OnclickListner on a custom listview adapter

android,android-listview,android-view,onclicklistener,baseadapter
I am newbie to Android so you can expect this a little silly but please do help. I have somewhat like custom listviews of people similar to whatsapp and other IM apps etc. Now when i click the listview i want to get the respective id of the clicked listview....

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

BaseAdapter and Picasso issue

java,android,listview,baseadapter,picasso
I am having a problem loading images in ListView from a server with Picasso. I have a BaseAdapter that is used to fill my ListView. In this ListView some items have an image and some not. in this method: public View getView(final int position, View convertView, ViewGroup parent) { I...

Setting an identifier for Listview items android

android,android-listview,baseadapter
I'm creating a listview from a database of people. When I click on the person I want to bring up the persons details. I want to set my own id for the person then bring up the details corresponding from this id. I tried to do this by adding a...

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

Xamarin (Android) - Can BaseAdapter return a different data type than Long when overriding GetItemID()?

android,xamarin,baseadapter
I am inheriting from BaseAdapter and overriding some of the methods. On of them is GetItemID(int iPosition). public override long GetItemId(int iPosition) { return moCustomModels[iPosition].EntityID; //EntityID is a type of Guid } The question here is - it does return Long data type and I need it to return Guid...

Get values spinner in listView(android)

android,listview,baseadapter
I apologize for my English. I thought a few days how to make a spinner in the ListView, and I was able to do it. But now I do not know how to take data from the spinner. I ask please tell me how to take the data from each...

How to load Different adapters on same listview on Button Click-[Android]?

button,android-listview,onclick,adapter,baseadapter
My requirement is to load different adapters on same listview using buttons to switch between adapters. I've tried this public class MainActivity extends ActionBarActivity implements View.OnClickListener { ImageButton fo,fl,ci,ani; ListView l; String flo[],foo[],cit[],an[]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String flo[] = {"Rose","Lily","SunFlower","Lotus","Tulips"}; String foo[] = {"Maggie","Manchurian","Pizza","Burger","French Fries"};...

Android Fragment BaseAdapter not working

android,fragment,baseadapter
This code works correctly in Activity,I change allContexts with getActivity() but when copy it to Fragment after adapter=new ListViewAdapter(getActivity(), arraylist); gets error When mylist.setAdapter(adapter) is running, , my error for class ListViewAdapter How to resolve this? Fragment public class Fragment1 extends Fragment { DataBaseHelper myDbHelper; ListView mylist; ArrayList<String> iran,arr_intityid,arrshomare,primarykeyarrlist; String[]...

Grid view view holder set wrong image when scrolling

android,gridview,baseadapter,android-viewholder
Problem: An ImageView is changed in a GridView cell after scrolling it. It works fine without a ViewHolder. Here a food icon changes to the last item, which was as default. // Grid view Adapter public class FlagTypAdapter extends BaseAdapter { Context ctx; ArrayList<Accounts> list; FlagTypAdapter adapter; Boolean isAtm; Activity...

listview issue from android version 4.4(kitkat) and above android version

android,listview,baseadapter
I am developing chat application.i am facing issue in listview odd behavior. My code is working perfectly below android OS 4.4. but when running my application in 4.4 kitkat then i am facing issue. please check below Screenshots. Suppose my First message length is large then my Second message height...

Java BaseAdapter - ArrayList as Return Value - NullpointerException

java,android,listview,arraylist,baseadapter
i´m trying to display a ListView of the last ten Database Objects. If i display those Objects in Labels everything works just fine but now i created a ListView + DataAdapter but the App crashes with a NullPointerException. I googled a lot but the only solution i found was that...

NullPointerException when adding an object to ArrayList in Android [duplicate]

java,android,android-listview,arraylist,baseadapter
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I'm trying to create a List View with BaseAdapter and i keep getting a Null Object Reference Error at the point of adding an object to an ArrayList....

Android: Cannot Pass Variable from BaseAdapter to Activity

android,variables,android-activity,baseadapter
I'm really new to android and I search a lot but still haven't managed to solve this.As the title says I'm trying to pass a variable from a baseadapter class to another activity I get a null exception error the moment I try to retrieve the string value. Here's my...

How to change background of non-visible buttons in GridView (Button adapter) from an activity

java,android,gridview,baseadapter
My code works only for visible views. mGridView = (GridView) findViewById(R.id.gridView); mGridView.setAdapter(new ButtonAdapter(this, list)); Method called when chronometer ticks: public void setBackground(int i) { Button button = (Button) mGridView.getChildAt(i); button.setBackgroundResource(R.drawable.button_shape); This method causes NPE because getChildAt cannot access non-visible childs. I tried some solutions found here but no luck so...

Navigation drawer listview position not refreshing

android,android-listview,navigation-drawer,baseadapter
I have one NavigationDrawer in my Application and I have five items in my drawer: Home Accounts stock help logout Now if user click on logout it is displaying two items: Home Login Now the issue is when user click on login it always getting view of Accounts public class...

LayoutInflater Exception using BaseAdapter

java,android,json,baseadapter
My class extends BaseAdapter and I am using Fragment but I am getting NullPointerException at this line: this.myInflater = LayoutInflater.from(activity); May I know what is the reason ? Why i am facing this issue ? How can i resolve this ? Adapter code: public class GridViewImageAdapter extends BaseAdapter { private...

Populate Expandable Listview from mysql crashes app

android,expandablelistview,baseadapter
I am trying to populate an expandable listview from the database and the app crashes without any log My code: The onCreateView: private View rootView; private ExpandableListView lv; private BaseExpandableListAdapter adapter; private String jsonResult; private String url = "http://reservations.cretantaxiservices.gr/files/getspirits.php"; ProgressDialog pDialog; ArrayList<ProductList> childs; String[] products; ArrayList<ExpandableListParent> customList; @Override public View...

How working system in getView in Android?

android,android-layout,android-activity,view,baseadapter
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = layoutInflater.inflate(R.layout.statistics_adapter, parent, false); } textViewLeft= (TextView) view.findViewById(R.id.textView); textViewRight= (TextView) view.findViewById(R.id.textView2); imageView= (ImageView) view.findViewById(R.id.imageView); textViewLeft.setText(title[position]); textViewRight.setText(str[position]); imageView.setVisibility(View.GONE);...

How to Call Adapter class before Activity

android,android-activity,android-listview,interface,baseadapter
Log says: D/CartActivity-onCreate(18171): onCreate D/CartActivity-TOTAL-InsideFORLOOP:(18171): 0.0 D/CartActivity-onResume(18171): onResume D/CartAdapter-TOTAL:(18171): 12.95 As you can see in above Log for loop is executed first in CartActivity and after the execution of onResume() method of CartActivity, CartAdapter is executing this line, therefore for i am getting 0.0 as value of Total in CartActivity...

ListView with custom adapter in Fragment

android,listview,android-fragments,fragment,baseadapter
Im trying to use ListView with custom adapter (baseAdapter) in fragmnet. When I us this code directly inside the MainActivity everything works fine, but when I use this in fragment it did't crash but it din't show anything, it is just a blank fragment. Also when I've tried to use...

Android - Make listview fill screen and list items to fill available space

android,android-layout,android-listview,baseadapter,android-layout-weight
So basically what I want to accomplish is make my screen be filled with a listview with exactly 4 immutable items (menu items). To do that, I created a Custom Adapter and an activity which holds a listview that uses this adapter. Basically I want to have 4 items filling...

How to Update the Text on click of list view items in baseadapter

android,listview,baseadapter
I am new in android and i am stuck in this problems , i have a text that will count the likes , onclick of like will set the total likes in text view.what code i ahve to written to increment the holder.likestatus on click of like. please help me....i...

How does my Adapter know about notifydatasetchanged

android,listview,baseadapter,notifydatasetchanged
I have a ListView, populated by a custom adapter: public class myAdapter implements ListAdapter This basic part is working - the views are created with the right data and all is good. The data underlying the list will change occasionally, and I need to be able to cause the whole...

How can i access fragment layout in parent activity?

java,android,android-fragments,gridview,baseadapter
I have got a tabpager and fragments. And a frament has got a "GridView". I am using a basedapter innerclass in the fragment parent activity. But when i want to set adapter to my gridview i m getting nullpointerexception. Because GridView variable is always null.how can solve this issue? Fragment...

Custom holder adapter error

android,baseadapter,android-viewholder
I'm trying to implement a listView with a checkbox as part of a bigger app. When I tried to start the activity, I got a nullPointer error but I'm not able to find out what's going wrong. Maybe my AsyncTask doesn't return a true value? Here is the logcat: https://www.dropbox.com/s/p8w9mz7lbofaeja/log.txt?dl=0...

Changing an item from a gridview

java,android,gridview,baseadapter
I'm trying to access the TextViews in my GridView, and change their background color so it changes when I call the playSoE method. ImageAdapter.java: public class ImageAdapter extends BaseAdapter { private Context mContext; private int mCount; public int[] mIds; //stores Ids from TextViews public ImageAdapter(Context c, int count) { mContext...

Android custom adapter Listview 1 selection causes multiple selections

android,android-listview,baseadapter,getview
I have a listview with custom adaptor with a toggle button, a spinner and some other views in it. This listview shows more items than can normally fit on 1 screen and this causes a weird problem which I don't understand. For example: When I press the toggle button of...

Set the progress dialog in base adapter

android,android-asynctask,progressdialog,baseadapter
This is my list view adapter in which I am sending listview data to server ans sqlite on the button clock asyn task. I want to use a progress dialog but I'm having problem while passing the activity's instance and my code crashes on the progress dialog. public class PlannningListViewAdapter...

radiogroup.setOnCheckedListener is not working as i expect.(Changing color of radio buttons)

java,android,listview,baseadapter
I'm having a activity which has question and answer section with a question with 4 choices in a radio group. On choosing answer it must change the background of answer to green or red(based on right or wrong). I have a activity which calls a BaseAdapter class which listens the...

Customized listview for dispaly files from sdcard

android,android-listview,baseadapter
I am using Customized listview to list files from SDcard with two buttons in each row. Below is my code. public class SDcardFiles extends BaseAdapter{ private ArrayList<File> mSdFilesList; private LayoutInflater mInflator; File myfilename; public SDcardFiles(File filename){ this.myfilename = filename; mSdFilesList = new ArrayList<File>(); mInflator = FileList.this.getLayoutInflater(); File list[] = myfilename.listFiles();...

Listview getView method not getting called

android,listview,android-listview,baseadapter,swiperefreshlayout
This type of question has been asked so many times but none of the solutions on SO are working for me so I am asking again for help. I have a custom ListView which implemented pull-to-refresh and was working fine until I decided to use the new SwipeRefreshLayout and now...

Retrofit: Callback doesn't access succes and failure methods

android,callback,baseadapter,retrofit
I'm trying to do a HTTP-POST using Retrofit. I have done this successfully in other classes, but now it doesn't work. Maybe because I am extending BaseAdapter instead of Activity or Fragment like I did before , but when I call the POST method it doesn't even access the succes...

Inflater button click listener not work

android,listview,button,onclicklistener,baseadapter
i have one custom listview and i want to give click listener into the Button ui object but it's not working, please kindly go through my below code and suggest me some solution. package com.example.dynamicbutton; import java.util.ArrayList; import android.annotation.SuppressLint; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import...

ListView Footer causes ArrayIndexOutOfBoundsException

java,android,android-listview,indexoutofboundsexception,baseadapter
I've a ListView with a footer (simple LinearLayout with a TextView and a ImageView), and a BaseAdapter with 2 View types: @Override public int getViewTypeCount() { return 2; } My problem is when I scroll the list to the bottom and reach the footer because this exception is thrown: java.lang.ArrayIndexOutOfBoundsException:...

android notifyDataSetChanged not working if delete item from data item

android,listview,baseadapter,notifydatasetchanged
I am developing an android application in which I am using one base adapter and displaying data in list form.Now what happened If I remove any object from list and if I call notifyDataSetChanged, its not working as expected. I tried this in following manner. @Override protected void onCreate(Bundle savedInstanceState)...

Custom list view is not replacing the view

android,android-listview,android-custom-view,baseadapter
I am showing an image and a text in a listView using custom Adapter.On clicking a button i want to replace the image with next image.But it is just getting added at the end of the list instead of replacing.Below is my code snippet: Method to fetch image from sqlite...

Updating a method in Fragment and BaseAdapter after item removed?

android,android-fragments,android-listview,baseadapter
I have an Fragment with a method that calculate itens of a sale. I have also a ListView with BaseAdapter inside this Fragment that show itens of sale. In this ListView has in each lines buttons that do remove itens of sale. In my Fragment I have a method that...

Using Custom Adapter with CursorLoader

android,baseadapter,custom-adapter,android-cursor,android-cursorloader
I'm trying to use CursorLoader to fetch data from my ContentProvider off the UI thread. I then use it to populate my list view. I was using SimpleCursorAdapter before and it works all fine. But now I want to have different views for the list view rows depending upon the...

Custom Listener on Button click in ListView Item

android,listview,interface,listener,baseadapter
I have created a Custom Listener interface for Button click in Adapter class, i followed this tutorial: http://www.c-sharpcorner.com/UploadFile/9e8439/create-custom-listener-on-button-in-listitem-listview-in-a/ Adapter: holder.btnQtyIncrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (customListner != null) { customListner.onButtonClickListner(position); } cart = cartArrayList.get(position); holder.textViewQuantity.setTag(cart); if(cart.getQuantity() == 9) { Toast.makeText(context, "Already...