android-adapter

Unable to use LayoutInflater in custom adapter

扶醉桌前 提交于 2019-12-18 15:54:58
问题 I'm looking into writing a custom adapter to populate a listview with 3 textviews per line. I've found quite a bit of example code to do this, but the one that seemed the best was at: http://www.anddev.org/custom_widget_adapters-t1796.html After a few minor tweaks to fix some compiler issues with the latest Android SDK, I got it running, only to get the exception: ERROR/AndroidRuntime(281): java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView So

android - listview filter count

百般思念 提交于 2019-12-18 13:11:54
问题 So after I set the filter on my listview: //Log adapter count before filter listView.getFilter().filter(searchStr) //Log adapter count after filter What I'm trying to achieve is to get the count of the result of that filtering. Like if before there are 10 items, then I apply the filter, so now only 5 items will appear, I want to get that count "5". I've tried checking the adapter count before and after the filter with no luck. They're displaying same count (I'm using a

Android CustomListAdapter notifydatachange() is not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 09:33:58
问题 I want to disply list of items using Custom ArrayAdapter . I will insert data by clicking a button. MainFragment.java @Override public void onClick(View v) { DatabaseClass feed = new DatabaseClass(getActivity()); new DatabaseClass(getActivity()).getList(); new MyFragment().updateList(); } My layout file is as follows. main.xml <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:id="@+id/update" android:name=

Custom adapter: get item number of clicked item in inflated listview

为君一笑 提交于 2019-12-18 09:27:00
问题 I have a custom baseadapter which does some lazy loading of some images, and then inflating the layout so I end up with a listview where I have both image and text in one row. When the user presses one item of the listview, say for example item 0 (top item), I want to show a dialog box with some specific content. This content depends on the item number - so the content shown for item 0 is not the same as for item 1, and so on. Here is the getView method of the custom adapter: public View

RecyclerView OnClick not working

浪子不回头ぞ 提交于 2019-12-18 06:07:53
问题 I have made a horizontal recyclerview inside a fragment. Now when I click on any item I don't see the on click listener working. Here is my code for the Adapter class: public class FeaturedProductsAdapter extends RecyclerView.Adapter<FeaturedProductsAdapter.CustomViewHolder> { private List<FeaturedProductInfo> feedItemList; private Context mContext; public FeaturedProductsAdapter(Context context, List<FeaturedProductInfo> feedItemList) { this.feedItemList = feedItemList; this.mContext =

How do I retrieve data independently from nested JSON objects that are part of the same group in android/java? ( more clarity/details in body)

穿精又带淫゛_ 提交于 2019-12-17 21:34:43
问题 I have a pretty common scenario, but I am stuck trying to figure out how to retrieve data from certain json objects within the same json response but returning different size of items. To make it less confusing, here's my json response: { "totalResults": 5, "meetings": [ { "id": "754e6670-2376-4eb2-b5f6-ea63ca7c2669", "dateStart": "2019-11-28T15:25:36.000Z", "dateEnd": "2019-11-28T23:00:36.000Z", "visitors": [ { "visitId": "34608af6-bbe4-439c-b472-500790385f60", "firstName": "Lord", "lastName

Android: Customize list view, Table view in adapter

允我心安 提交于 2019-12-17 19:57:05
问题 I created a table view in list view adapter programmatically. For that first i created a Adapter layout as : <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:stretchColumns="*" android:id="@+id/tablelayout" > </ableLayout> Then what I have done in the adapter is: public class DemoAdapter extends ArrayAdapter

Android: Radio button in custom list view

自作多情 提交于 2019-12-17 08:53:25
问题 I am developing an application in which I need to implement radio buttons in list view. I want to implement a list view having one radio button and two text view in each row. And one button "Ok" below listview. What I have done is I created a list view and a custom adapter. The code of listview is as: <ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:cacheColorHint="#00000000" android:overScrollMode="never" tools:ignore=

findViewById vs View Holder Pattern in ListView adapter

耗尽温柔 提交于 2019-12-17 02:09:36
问题 I always use LayoutInflater and findViewById for creating new item in the getView method of an Adapter . But in many articles people write that findViewById is very very slow and strongly recommend to use the View Holder Pattern. Can anyone explain why findViewById is so slow? And why the View Holder Pattern is faster? And what should I do if needed to add different items to a ListView ? Should I create classes for each type? static class ViewHolderItem1 { TextView textViewItem; } static

How to update RecyclerView on dataset changes?

怎甘沉沦 提交于 2019-12-14 02:51:24
问题 I'm using ActiveAndroid ORM and UltimateRecyclerView in my Android application. I don't know how to display a data in a list using this popular libraries. I know, the data is saved to database correctly. Using the following method, I'm getting a cursor to the data I want to display. public Cursor eventsCursor() { // `Event` is an ActiveAndroid model class String query = new Select() .from(Event.class) .orderBy("time") .toSql(); return ActiveAndroid.getDatabase().rawQuery(query, null); } I