adapter

Listview with custom adapter containing CheckBoxes

扶醉桌前 提交于 2019-11-27 01:58:12
问题 I have a ListView which uses a custom adapter as shown: private class CBAdapter extends BaseAdapter implements OnCheckedChangeListener{ Context context; public String[] englishNames; LayoutInflater inflater; CheckBox[] checkBoxArray; LinearLayout[] viewArray; private boolean[] checked; public CBAdapter(Context con, String[] engNames){ context=con; englishNames=engNames; inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); checked= new boolean[englishNames.length

What's the purpose of item-id's in Android ListView Adapter?

微笑、不失礼 提交于 2019-11-27 01:52:41
(Not specific to ListView, but to Adapter). I keep implementing this when I subclass BaseAdapter: @Override public long getItemId(int position) { return position; } Because have to implement that. I don't see any use of it, I need getItem(position) only, not getItemId(position). I wonder if it has any significance (to Android SDK or something else)? There are probably many reasons to have stable item IDs. A default implementation cannot be given since it depends on the type of Object being stored in the Adapter. Android has a check to make sure that item IDs are used only when they are stabled

Android: notifyDataSetChanged(); not working

梦想的初衷 提交于 2019-11-27 01:44:31
I have a database in a server and from a Tablet I take some values from one table in the database. I load this information correctly into a list but I would like to know why when there is a change, nothing happens even if I use notifyDataSetChanged(); . I must say that for loading the loading data y use the AsyncTaskClass So, my problem is that I don't know if use the notifyDataSetChanged(); method correctly ,because if there's is a change I would like to refresh the image. Here is some part of the code of the class: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

A C++ iterator adapter which wraps and hides an inner iterator and converts the iterated type

假如想象 提交于 2019-11-27 01:37:52
问题 Having toyed with this I suspect it isn't remotely possible, but I thought I'd ask the experts. I have the following C++ code: class IInterface { virtual void SomeMethod() = 0; }; class Object { IInterface* GetInterface() { ... } }; class Container { private: struct Item { Object* pObject; [... other members ...] }; std::list<Item> m_items; }; I want to add these methods to Container: MagicIterator<IInterface*> Begin(); MagicIterator<IInterface*> End(); In order that callers can write:

ClassCastException with ListView when executing notifyDataSetChanged

末鹿安然 提交于 2019-11-27 01:28:09
问题 I have added a view to the header of listVivew, View TopSearch = (View) View.inflate(this, R.layout.search, null); lv.addHeaderView(TopSearch, null, false); And everything is fine until I try to execute (when data changes) adapter.notifyDataSetChanged(); That always crash my application giving me following error: > java.lang.ClassCastException: android.widget.HeaderViewListAdapter If I remove header view then there is no error. Any suggestions? Thanks. 回答1: It seems that whenever you use

How to start Activity in adapter?

[亡魂溺海] 提交于 2019-11-27 00:25:47
I have a ListActivity with my customized adapter. and inside each of the view, it may have some buttons, in which i need to implement OnClickListener. I need to implement the OnClickListener in the adapter. However, I dont know how to call the function like startActivity() or setResult(). since the adapter doesnt extend to Activity. so what is the best way to solve this problem ? thanks Just pass in the current Context to the Adapter constructor and store it as a field. Then inside the onClick you can use that context to call startActivity(). pseudo-code public class MyAdapter extends Adapter

Sync Adapter without Account

陌路散爱 提交于 2019-11-27 00:03:31
问题 I need to fetch some data over the cloud from my app. I've watched the google IO video on RESTful android apps @ http://www.youtube.com/watch?v=xHXn3Kg2IQE&t=43m58s It recommends in the final slides to use a SyncAdapter to integrate with the Android System. Later I learned that one has to use an Account to implement SyncAdapter. My app does not use an account. Users can freely download data without registration. Can I still use SyncAdapter? Is there a stock dummy account that I could use?

ArrayIndexOutOfBoundsException with custom Android Adapter for multiple views in ListView

廉价感情. 提交于 2019-11-26 23:36:01
I am attempting to create a custom Adapter for my ListView since each item in the list can have a different view (a link, toggle, or radio group), but when I try to run the Activity that uses the ListView I receive an error and the app stops. The application is targeted for the Android 1.6 platform. The code: public class MenuListAdapter extends BaseAdapter { private static final String LOG_KEY = MenuListAdapter.class.getSimpleName(); protected List<MenuItem> list; protected Context ctx; protected LayoutInflater inflater; public MenuListAdapter(Context context, List<MenuItem> objects) { this

ECMA TypeError calling Java class from Worklight adapter

白昼怎懂夜的黑 提交于 2019-11-26 23:30:54
问题 I've seen a number of questions about this issue but no conclusive answers. I am having trouble calling a Java class from my Worklight adapter implementation. I replaced my code with the code from the IBM Worklight Java Adapter tutorial and it fails in the exact same way. Furthermore I found a response on IBM's site saying the Java 1.7 compiler might cause this problem and to use Java 1.6 instead. I validated that my compiler in Eclipse is Java 1.6. My Java classes all begin with com (e.g.

ArrayAdapter text and image

独自空忆成欢 提交于 2019-11-26 23:24:57
问题 In my activity I implement a list which contains the names of some files. Every list's item refers to a layout in which I'd like to show the name of the images and a thumbnail of the image referenced. Ican show the the name using an ArrayAdapter but i don't know hot to insert the image thumbnail. All the image referenced stay in sd_card and i have the path of they. Here is the single row layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk