adapter

Why set setBackgroundColor is not working in my custom listView

岁酱吖の 提交于 2019-11-30 17:15:14
I have a custom listView. The main layout xml is something like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:layout_height="wrap_content" android:id="@+id/lv_clientes" android:layout_width="0dp"> </ListView> <!-- From this part there are not problems --> </LinearLayout> The list item XML is this <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res

Asynchronous download of Bitmaps in an Adapter, with emphasis on Bitmap.recycle()

痞子三分冷 提交于 2019-11-30 17:00:16
问题 Could someone tell me how to make a good mechanism for async. download of images for use in a ListView/GridView? There are many suggestions, but each only considers a small subset of the typical requirements. Below I've listed some reasonable factors (requirements or things to take into account) that I, and my collegues, are unable to satisfy at once. I am not asking for code (though it would be welcome), just an approach that manages the Bitmaps as described. No duplication of downloaders or

Why set setBackgroundColor is not working in my custom listView

对着背影说爱祢 提交于 2019-11-30 16:32:31
问题 I have a custom listView. The main layout xml is something like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:layout_height="wrap_content" android:id="@+id/lv_clientes" android:layout_width="0dp"> </ListView> <!-- From this part there are not problems --> </LinearLayout> The list item XML is this <

适配器模式

妖精的绣舞 提交于 2019-11-30 15:11:18
适配器模式简介 在现实生活中,经常出现两个对象因接口不兼容而不能在一起工作的实例,这时需要第三者进行适配。例如,讲中文的人同讲英文的人对话时需要一个翻译,用直流电的笔记本电脑接交流电源时需要一个电源适配器,用计算机访问照相机的 SD 内存卡时需要一个读卡器等。 在软件设计中也可能出现:需要开发的具有某种业务功能的组件在现有的组件库中已经存在,但它们与当前系统的接口规范不兼容,如果重新开发这些组件成本又很高,这时用适配器模式能很好地解决这些问题。 适配器模式属于结构型模式 适配器模式涉及3个角色: 源(Adaptee) :需要被适配的对象或类型,相当于插头。 适配器(Adapter) :连接目标和源的中间对象,相当于插头转换器。 目标(Target) :期待得到的目标,相当于插座。 主要可以分为 类适配器 对象适配器 接口适配器 适配器模式应用实例 以生活中充电器的例子来讲解适配器,充电器本身相当于Adapter,220V交流电 相当于src (即被适配者),我们的目dst(即 目标)是5V直流电 类适配器: //被适配的类 public class Voltage220V { //输出220V的电压 public int output220V() { int src = 220; System.out.println("电压=" + src + "伏"); return src;

Simpler use of TypeAdapterFactory

烈酒焚心 提交于 2019-11-30 11:45:58
AFAIK the most flexible gson customization is possible via TypeAdapterFactory , however it may get needlessly complicated. It forces me to write for each handled class both read and write , while sometimes only one method is really needed. Moreover, sometimes a JsonSerializer and/or JsonDeserializer were much easier to write, e.g. like here . This leads me to these questions: Is it possible to write a TypeAdapter which simply delegates one of its methods (e.g. writing of ImmutableList to writing of List )? Is it possible to somehow use JsonSerializer and/or JsonDeserializer together with the

Filter for android ListView - Space Character

浪尽此生 提交于 2019-11-30 10:06:12
I want to filter my listView using an EditText box and using the adapter getFilter() function. It works just fine until I put a space character in the text box. Edit: It's a SimpleAdapter not ArrayAdapter If my list contains these words: {"Apple", "Banana", "Red Apple"} If I type "apple" it will return all the items containing the word apple in it (Apple and Red Apple). If I type "apple " it won't returning anything. Any ideas? Here's the code: searchBox = (EditText) findViewById(R.id.searchBox); searchBox.addTextChangedListener(filterTextWatcher); and private TextWatcher filterTextWatcher =

post image using worklight http adapter proper format

本小妞迷上赌 提交于 2019-11-30 10:05:39
问题 I am trying to post an image (as part of a form) to a PHP server from a Worklight V6 app using the HTTP adapter. The image is base64 encoded navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 8, destinationType: navigator.camera.DestinationType.DATA_URL }); .. later in the code $('#myImageImg').attr('src', "data:image/jpeg;base64," + imageData); I send the image to the adapter var img = $('#myImageImg').attr('src'); var formData = {"someField" : name, "image" : img }; var

Listview not updating after database update and adapter.notifyDataSetChanged();

瘦欲@ 提交于 2019-11-30 07:42:35
问题 I was browsing the net for 2 days allready and tryed alot of stuff but can't seem to figure out what is wrong with this. I am still fairly new to the Android deevelopment so I probably missed something obvious. I have an app witch is using a sqllite databse to store some data and for the porpose of this Proof of concept displaying that in a listview. I can add items to the list, delete them. So far so good. The problem I have is when I instead of delete update a column in the databse called

Using AsyncTask to load images into a custom adapter

拜拜、爱过 提交于 2019-11-30 07:20:44
Although there are many tutorials out there, I've found it really difficult to implement an AsyncTask to load images from URI's (obtained from a content provider) into a custom adapter. I get the basic gist, which is to have a class containing an AsyncTask, do the bitmap creation in the 'doInBackground', and then set the ImageView in the onPostExecute. The problem for me, being new to android & programming, is that I don't know how to pass in my Uri's to the AsyncTask for each item, how to create the bitmap, and how to return it to the adapter. I've only gotten this far with the actual

JAXB: Isn't it possible to use an XmlAdapter without @XmlJavaTypeAdapter?

删除回忆录丶 提交于 2019-11-30 06:28:07
Can't I register a bunch of XmlAdapter s to Marshaller | Unmarshaller so that I wouldn't need to specify @XmlJavaTypeAdapter on each filed, whose type isn't natively JAXB-supported? I find it somewhat redundant . BTW, someMarshaller.setAdapter(...) seem not to do anything. user1128134 This is a quite a good question ! The short answer is that no , using setAdapter on marshaller / unmarshaller does not mean that you don't have to use @XmlJavaTypeAdapter . Let me explain this with a hypothetical (yet valid!) scenario. Consider in a web application, one fetches an event in the form of xml having