custom-adapter

filtering custom adapter IndexOutOfBoundsException

只愿长相守 提交于 2019-12-01 15:09:06
问题 I'm novice at android. My custom Adapter cause exception when filtering. here is my code. private class DeptAdapter extends ArrayAdapter implements Filterable { private ArrayList<Dept> items; private ArrayList<Dept> mOriginalValues; public DeptAdapter(Context context, int textViewResourceId, ArrayList<Dept> items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v ==

Out Of Memory Exception with custom GridView [duplicate]

断了今生、忘了曾经 提交于 2019-12-01 11:21:42
This question already has an answer here: Strange out of memory issue while loading an image to a Bitmap object 43 answers I have this code of a custom grid view and each time I try to run it, it crashes caused by an OutOfMemoryException . I guess the solution is to resize the images in the array ... main activity code : public class AndroidGridLayoutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); GridView gridView = (GridView) findViewById(R.id.grid_view); // Instance of

Out Of Memory Exception with custom GridView [duplicate]

佐手、 提交于 2019-12-01 09:24:18
问题 This question already has answers here : Strange out of memory issue while loading an image to a Bitmap object (43 answers) Closed 5 years ago . I have this code of a custom grid view and each time I try to run it, it crashes caused by an OutOfMemoryException . I guess the solution is to resize the images in the array ... main activity code : public class AndroidGridLayoutActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState)

TextView in listview rows showing repeated values on scroll in Android?

送分小仙女□ 提交于 2019-12-01 05:47:14
I am working with custom Adapter of a ListView in which I have a TextView and a Spinner. After selecting the values from a Spinner, the value after copied to the TextView of the respective same Row of list. Problem is, As I have more than 40 elements in the ListView , when I select the first spinner and set the value to the respective TextView, on scroll, the same value is seen in the 10th Row TextView. Values are copied from 1st TextViewto 10th TextView on scroll. Below is the code which I am using: public class AppListAdapter extends BaseAdapter { private LayoutInflater mInflater; private

butterknife @OnClick inside ViewHolder in CustomAdapter

杀马特。学长 韩版系。学妹 提交于 2019-12-01 04:44:11
问题 I'm currently learning butterknife, and I need to bind specific @OnClicks on different views generated by my customer adapter. How do I go about with this? I've seen an answer in one of the questions here saying that he uses '@onclick' inside the 'ViewHolder'. I'm not sure how to implement this exactly. Any ideas? Thanks! 回答1: Imagine you have a ViewHolder like this. static class ViewHolder { @InjectView(R.id.user_name) TextView userName; @InjectView(R.id.user_title) TextView userTitle;

Items in listView have white text when using setAdapter in UI thread

女生的网名这么多〃 提交于 2019-12-01 03:28:38
For another listView in another activity the text color of the items is black, like it should be. However, in another activity when using setAdapter in a new thread when the new items created the text color is white when I want it black. Here is the contents of Layout and Java code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="project.yemeb.Search" android:background="#ffffffff"> <RelativeLayout android:layout_width="fill_parent"

TextView in listview rows showing repeated values on scroll in Android?

百般思念 提交于 2019-12-01 03:06:54
问题 I am working with custom Adapter of a ListView in which I have a TextView and a Spinner. After selecting the values from a Spinner, the value after copied to the TextView of the respective same Row of list. Problem is, As I have more than 40 elements in the ListView , when I select the first spinner and set the value to the respective TextView, on scroll, the same value is seen in the 10th Row TextView. Values are copied from 1st TextViewto 10th TextView on scroll. Below is the code which I

custom adapter for listview in fragment Android

懵懂的女人 提交于 2019-12-01 01:13:05
hi i m learning android listview , anyone give idea on How to set CustomAdapter into fragment activity? Below is simple listview for fragment. For customListview in Fragment Activity not other how to proceed... public class CallFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_top_rated, container, false); ListView listview = (ListView) rootView.findViewById(R.id.listView1); String[] items = new String[] { "Item 1", "Item 2", "Item 3" }; ArrayAdapter<String> adapter

How could i add a spinner in listview with its listitems by using customadapter?

两盒软妹~` 提交于 2019-11-30 21:18:31
问题 I am using a listview and there are number of listitems. I need to add a spinner with all my listitems. I am using customadapter and my problem is for adding a image we can use imageview. For spinner what can i use? 回答1: Here is the code. package com.android.main; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android

notifyDataSetChange not working on RecyclerView [duplicate]

旧时模样 提交于 2019-11-30 10:53:35
This question already has an answer here: Update ListView in the main thread from another thread 6 answers I'm working with Android's new RecyclerView but I can't get my custom adapter to refresh whenever I call one of the "notify" methods. I've tried calling notifyDataSetChanged, notifyItemRangeInserted and notifyItemInserted and none of them seem to work. Here's the code for my custom adapter. I'm basically trying to refresh a list of Strings: package com.mycompany.myapp.adapters; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View;