custom-adapter

Null pointer exception in getView() of custom Adapter

五迷三道 提交于 2019-12-11 19:35:42
问题 I am using this Custom Adapter for my ListView: public class SideMenuAdapter extends BaseAdapter { private static final int TYPE_MAX_COUNT = 2; private static LayoutInflater inflater = null; private Activity activity; public static String[] values; ListView myList; public SideMenuAdapter(Activity a, String[] sa, ListView lv) { values = sa; activity = a; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); myList = lv; } public int getCount() { return values

Having trouble passing object between fragments

非 Y 不嫁゛ 提交于 2019-12-11 18:08:40
问题 I have been spending my time for several days with this question and getting same error. I have been trying to pass object between fragments which are held in action bar. Please tell me where i make the mistake. Here my code: package com.restaurantexample.fragment; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view

clear + addAll vs re-initialise list RecyclerViewAdapter android

ぃ、小莉子 提交于 2019-12-11 16:04:58
问题 What's the different between 1 and 2: 1. public void updatePostList(ArrayList<Post> updatedPosts) { this.postList.clear(); this.postList.addAll(updatedPosts); notifyDataSetChanged(); } 2. public void updatePostList(ArrayList<Post> updatedPosts) { this.postList = updatedPosts; notifyDataSetChanged(); } For me, #1 doesn't work as calling this.postList.clear() clears updatedPosts too instead of just clearing postList and I can't understand why. 来源: https://stackoverflow.com/questions/56454443

Text not showing up in ListView when using a custom adapter

回眸只為那壹抹淺笑 提交于 2019-12-11 15:38:31
问题 For some reason, I can't get text to show up in my list view. When I run the following example, two blank list elements appear with no text. Also, the debugging output shows that the value of the text in the TextView is correct. Here is my main activity: import java.util.ArrayList; import android.app.ListActivity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;

How to show title of a row in a textview in Main Activity when an image in the row is clicked

ε祈祈猫儿з 提交于 2019-12-11 14:36:08
问题 I have a custom adapter with an image in each row .On clicking the image i would like to display the title of the row that the image is part of. I have implemented an interface in my activity that allows me to display a relative layout whenever the image is clicked where the textview that displays the row title exists.This relative layout is in in my activity_main.xml. Problem: I have been able to accomplish all his except that only the title of the first row is displayed across all the other

Use of condition if(view==null) in CustomAdapters

自作多情 提交于 2019-12-11 13:12:52
问题 I am writing a custom adapter for ListView which extends BaseAdapter and in this method @Override public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; if (vi == null) vi = inflater.inflate(R.layout.x, null); } why is the check if(vi==null) performed. getView() is called for row when it comes in the visible area of the screen. So vi will be null everytime getview() is called? So why is the check necessary here.? P.S. I was getting some problem on

Handling imageButton clicks inside a custom listview

∥☆過路亽.° 提交于 2019-12-11 09:00:10
问题 I have a listview with a custom Adapter. A custom row in the listView containts 2 imagebuttons that need to handle a something when I click on it. But it doesn't work well like I want, because when I start the app and click on the imagebutton then nothing happens, but if I first click on the row and then on the imageButton, then my click is being handled. I tried a few solutions that helped other users here SO, but nobody had the exact same problem as me that it gets handled after a row click

Android Filtered list item not removing after click

[亡魂溺海] 提交于 2019-12-11 07:58:17
问题 I have a custom adapter extends Base adapter and implements Filterable. When i write something to searchview filter is working well. Before filtering when i click the list item of listview, it is removed successfully. But after filtering when i click the list item, its not removing . How can i fix this problem ? 1 1 2 2 3 3 4 4 adapter: public class kisiler_adapter extends BaseAdapter implements Filterable{ private Context mContext; private List<kisiler> kisilerList; private List<kisiler>

Custom arrayadapter and onclicklistener for a button in a row

ε祈祈猫儿з 提交于 2019-12-11 07:41:03
问题 I have a custom arrayadapter and I want to add an onclicklistener for a button in each one of its rows, when I click on the button I want the image resource to change, everything works fine except that when I click on a button the image changes but the image of another button in an other row also changes. Thanks for your help ! Here is my code: public class Coursadapter extends ArrayAdapter<String>{ Context context; int layoutResourceId; ArrayList<String> data = null; WeatherHolder holder;

Android Custom Adapter Filter not working

不问归期 提交于 2019-12-11 06:57:40
问题 I am using a custom adapter with a search filter in a fragment, however the results don't get filtered on a search, I debugged and stepped through my code and find that it is saying that the args.listenere = null! . What does this mean and how do I correct it? My code is below: ---------Custom Adapter ------- public class SalesPartAdapter extends BaseAdapter implements Filterable { private ArrayList<SalesPartItem> listData; private ArrayList<SalesPartItem> filteredData; private