adapter

Android Radio buttons in a custom listview changes its state when we scroll the list

陌路散爱 提交于 2019-11-30 05:42:41
问题 I am a beginner and facing a problem where I am creating a ListView with two RadioButton s and a TextView . Everything goes fine, but when I set RadioButton s and scroll it, the values of previous RadioButton s change their values or lose their state dramatically. I am trying to solve this problem for long time. What changes should I make to overcome this problem? MainActivity.java public class MainActivity extends Activity { private ListView listView1; @Override public void onCreate(Bundle

Linux相关函数

£可爱£侵袭症+ 提交于 2019-11-30 04:27:54
目录 内核、用户数据拷贝 module_platform_driver() 驱动获得进程的信息 DEVICE_ATTR EXPORT_SYMBOL() container_of insmod给驱动传参数 其他函数 内核、用户数据拷贝 常见的有四个函数: copy_from_user、copy_to_user、get_user(或__get_user)、put_user(或__put_user) copy_from_user: 原型:static inline long copy_from_user(void *to, const void __user * from, unsigned long n) 第一个参数to: 内核空间的数据目标地址指针 第二个参数from: 用户空间的数据源地址指针 (void __user *也可) 第三个参数n: 数据的长度,以字节为单位。 如果数据拷贝成功,则返回零;否则,返回没有拷贝成功的数据字节数。 例: static struct file_operations ker_rw_ops = { .owner = THIS_MODULE, .unlocked_ioctl = ker_rw_ioctl, }; static long ker_rw_ioctl(struct file *file, unsigned int cmd, unsigned

android listview displays false data after scrolling (custom adapter)

百般思念 提交于 2019-11-30 04:19:07
问题 I've got a strange problem that drives me crazy. In my android application I customized my own adapter that extends from ArrayAdapter. The items of the ListView to which I added my adapter can either be labeled-text (not editable), editable text or a spinner. The crazy stuff is: when I scroll the ListView, there are two problems: (1) the (selected) value that is shown in the spinner items changes sometimes although I only scrolled!! when I click on the spinner, the old selected value is still

ViewPager PagerAdapter with cursor - CursorLoader.onLoadFinished doesnt get called with different query

Deadly 提交于 2019-11-30 04:18:08
I am doing like a quote application that pulls the quotes from the database and I need to display quotes in a ViewPager. I have created my CursorPagerAdapter which seems to work well. public class MyCursorPagerAdapter extends PagerAdapter { private Cursor cursor; private LayoutInflater inflater; public MyCursorPagerAdapter(Context context, Cursor cursor) { Log.d(MainActivity.TAG, "MyCursorPagerAdapter.onCreate()"); this.cursor = cursor; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void swapCursor(Cursor cursor) { //if(cursor != null) {

ViewPager + Adapter in Fragment => laggy swiping

女生的网名这么多〃 提交于 2019-11-30 04:09:33
I have a ViewPager with some fragments. Each fragment has a ListView in a SlidingDrawer (=invisible before swiping) with an ArrayAdapter . Adapter is set on onCreateView() , that slows down swiping, because 30 list items have to load each time I swipe, because new fragments are being created. My Question is, whether it is possible to set the adapter after swiping when it ViewPager is idle? Or is there a better way? The List needs to be already loaded when the SlidingDrawer is expanded. My Question is, wether it is possible to set the Adapter after swiping when it Pager is idle? There is the

How to know which view inside a specific ListView item that was clicked

有些话、适合烂在心里 提交于 2019-11-30 03:40:30
I'm having a ListView with my own custom adapter derived from a BaseAdapter . Each item in the ListView has sub items such as ImageView and TextView . How can I know which one of these sub items the user clicked? Is it possible to attach a listener in the getView function for example, or could that be a problem? / Henrik Edit: Currently I have a onItemClick in the Activity which contains the ListView . Is there any good way to know which sub item in a specific item in the ListView which has been pressed by checking the params in the onItemClick . @Override public void onItemClick(AdapterView<?

Treat Enumeration<T> as Iterator<T>

我的未来我决定 提交于 2019-11-30 01:47:05
问题 I have a class that implements the Enumeration<T> interface, but Java's foreach loop requires the Iterator<T> interface. Is there an Enumeration to Iterator Adapter in Java's standard library? 回答1: You need a so called "Adapter", to adapt the Enumeration to the otherwise incompatible Iterator . Apache commons-collections has EnumerationIterator. The usage is: Iterator iterator = new EnumerationIterator(enumeration); 回答2: If you just want something to iterate over in a for-each loop (so an

How to sort RecyclerView item in android

你说的曾经没有我的故事 提交于 2019-11-30 00:45:46
问题 I'm working on a android chatting application. When I called my api it returns me the chat list sorted by a user_id. But what I need to do is serialized by message_id as I want to show last message first.Here is my onBindViewHolder method in which i get the values. public void onBindViewHolder(final MyAdapter_HomeViewHolder holder, final int position) { holder.userNameTV.setText(data.get(position).getUserInfo().getFullName()); holder.msgBodyTV.setText(data.get(position).getBody()); holder

Uncheck all checkboxes in a custom ListView

依然范特西╮ 提交于 2019-11-29 20:51:28
问题 I'm trying to do an "Unselect all" button in a ListActivity to unchecked all checkboxes in a ListView managed by a custom SimpleCursorAdapter. As suggested here, I tried In my ListActivity I have: Button bt_f_unsel = (Button) findViewById(R.id.btn_f_unsel); bt_f_unsel.setOnClickListener(new OnClickListener() { public void onClick(View v) { for ( int i=0; i< getListAdapter().getCount(); i++ ) { mListView.setItemChecked(i, false); } } }); but nothing happens. I'm wondering if this is because of

设计模式——适配器模式

ⅰ亾dé卋堺 提交于 2019-11-29 17:48:56
1:什么是适配器模式   当客户需要一个A,可是厂家1没有A只有C,厂家2没有A只有D。这时候就需要一个适配的角色,将C、D客户需要的A。 2:角色   目标角色:就是客户需要的A   适配角色:就是厂家1的C,厂家2的D   适配器角色:就是将C、D转换成A 3:具体的代码   adapter接口:客户需要的A   adpater1类:厂家的medC、medD   adapter实现类:适配器的角色,将厂家的medC、D装换成客户需要的A adapter接口:public interface Adapter { public String medA1(); public String medA2(); } adpater1类public class Adapter1 { public String medB(){ return "medB"; } public String medC(){ return "medC"; } } adapter实现类public class Adpater1Impl implements Adapter { private final Adapter1 adapter1; public Adpater1Impl(Adapter1 adapter1) { this.adapter1 = adapter1; } @Override public