baseadapter

Filtering list of apps in custom baseadapter

空扰寡人 提交于 2019-12-06 16:21:33
问题 I am trying to implement a searchview for my listview of my installed apps with my baseadapter class. Currently it looks like this: The problem is that when I hit it crashes with 09-02 19:56:47.925 1628-1628/com.spicycurryman.getdisciplined10.app.dev E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.spicycurryman.getdisciplined10.app.dev, PID: 1628 java.lang.NullPointerException at com.spicycurryman.getdisciplined10.app.BlockActivity$2.onQueryTextSubmit(BlockActivity.java:126) because I'm

context parameter for custom adapter - getApplicationContext() fails but 'this' works

吃可爱长大的小学妹 提交于 2019-12-06 15:31:38
I have simple code snippet to implement custom list view. In this code, I have CustomAdapter class which extends ArrayAdapter : CustomAdapter adapter = new CustomerAdapter(getApplicationContext(),R.layout.listview_item_row, weather_data); The constructor of CustomAdapter is as below: public CustomerAdapter(Context context, int layoutResourceId, weather[] data) { super(context, layoutResourceId, data); mlayoutResourceId = layoutResourceId; mcontext = context; mdata = data; } If I write this, the logcat shows following error: Java.lang.ClassCastException: android.app.Application context can not

Update ActionBar from Adapter

自古美人都是妖i 提交于 2019-12-06 11:45:42
问题 I have a basket icon with count notification on it in actionbar for showing number of goods in shopping basket. also I have a custom view containing a button for add goods to shopping basket. I want that when I click on button (in custom view) notification count on basket icon increases. I use this function in main activity to update notification count but notification does not update. public static void updateCountBasket(final int number , int id , View view ,Context context) { if (view

postition of ticked (checked) checkbox changes after filtering data of Listview

[亡魂溺海] 提交于 2019-12-06 09:59:03
问题 I am trying to apply filter on my custom adapter which extends BaseAdapter , in which I am facing some problems, after I filter input based on the text in EditText and check the CheckBox to select one value and if I erase the text in the EditText to search for some other thing the position of the checked checkbox changes automatically as you can see in the image attached below. I am currently facing two problems 1 - Position of the ticked checkbox changes automatically 2 - If I type in

Fragment doesn't respect match parent height when having listview row item has hidden view in it

坚强是说给别人听的谎言 提交于 2019-12-06 08:23:13
I am having a weird issue in my app. In one of my app activity I am inflating three fragments in it with tabs. Everything works fine. In the fragment in which I am having problem, I have listview which is inflated using adapter and data fro web service. This also works well. Now the problem is this the row which is inflated in adapter, has a hidden view which has visibility=gone in xml. On tap of imageview from that row I make that layout visible through java code. The problem is layout doesn't become visible on tap. I have even set breakpoint on the onClickListener of imageview and it does

custom ListView with checkboxes checking unchecked items

时光怂恿深爱的人放手 提交于 2019-12-06 06:47:13
问题 i have a BaseAdapter for my ListView inside a fragment that looks like this: public class SelectionMucListAdapter extends BaseAdapter { private LayoutInflater inflater = null; Typeface titleFace; ArrayList<UsersData> innerList = new ArrayList<UsersData>(); public SelectionMucListAdapter(ArrayList<UsersData> users) { inflater = (LayoutInflater) mainActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); titleFace = Typeface.createFromAsset(mainActivity.getAssets(), "fonts/bradybun.ttf");

getView() position is repeating in BaseAdapter -Android

筅森魡賤 提交于 2019-12-06 06:18:19
In my Android Application I am showing a list of Cards. I am using BaseAdapter. All cards are visible to me on the ListView but I am getting an issue. getView() is called with repeated positions due to the first card not showing the correct image. It is using the image from the 2nd to last card. I spent a day to fix it. I visited many stackoverflow answers, but no luck. Help me please. @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder = null; LayoutInflater mInflater = (LayoutInflater)context.getSystemService(Activity.LAYOUT_INFLATER

android listview order changed when called notifyDataSetChanged

China☆狼群 提交于 2019-12-06 05:50:31
all. when I use notifyDataSetChanged(), the listview display order will be change . like this 3 2 1 when current activy was created. but when I change the data. it will be 1 2 3 I don't want the order changed and i dont understand why its happening. This is a piece of code from my adapter class public static class ItemAdapter extends BaseAdapter { private String[] mData; private LayoutInflater mInflater; // I called this method to change data public void setEditText(int position, final String item) { mData[position] = item; notifyDataSetChanged(); } } I change data at some dialog like this

Position index always return 0 in getView

こ雲淡風輕ζ 提交于 2019-12-05 21:49:05
i want to implement a ListView which have Delete Btn inside of each row. My only problem is when i click Delete Btn of some Row, Row with Position 0 just Deleted! i think somehow my Position parameter in getView cannot be updated and always have 0 value what should i do?! Thanks. import java.util.ArrayList; import android.app.Activity; import android.content.Context; //import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button;

Why is CursorAdapter different from BaseAdapter?

六眼飞鱼酱① 提交于 2019-12-05 12:07:55
I would like to ask why CursorAdapter splits the process of creating a view and populating it with data into newView() and bindView() while BaseAdapter only does this with getView() ? From Source code of CursorAdapter.java , CursorAdapter extends BaseAdapter . And you can see getView() function implementation: public View getView(int position, View convertView, ViewGroup parent) { if (!mDataValid) { throw new IllegalStateException("this should only be called when the cursor is valid"); } if (!mCursor.moveToPosition(position)) { throw new IllegalStateException("couldn't move cursor to position