adapter

一行代码搞定Adapter

自古美人都是妖i 提交于 2019-12-17 16:50:08
15年Google I/O大会发不了三个重要支持库 >Material design (Android Support Design) >百分比布局:Percent support lib >数据绑定: Data Binding Library 如果你还不没用过Data Bind Library 没关系 那你知道ButterKnife吧 DataBindLibrary 和ButterKnife都是编译时期生成相应的注解文件 因此 在性能上不会有什么大的影响 因此放心的尝试吧。(个人感觉DataBind 比ButterKnife 稍微复杂一些 但是用起来也比较爽一些 后面会附上关于 Data Binding使用的一些链接) 一行代码搞定Adapter: 基于 RxJava + Data Binding + RxRecyclerView new RxDataSource<String>(dataSet).repeat(1).bindRecyclerView (fragmentBinding.mGridView,R.layout.item_homepage_gridview) .subscribe(stringViewDataBindingSimpleViewHolder -> { }); 详情见 github: https://github.com/ahmedrizwan

Callback from Adapter

别来无恙 提交于 2019-12-17 16:46:18
问题 So I have a custom listview. It's like Instagram layout with 1 image and bunch of buttons in each list items. So here's the problem: I want to implement the share button. To do this, I tried to create a callback from adapter to activity. But it didn't seem to work. Here is what I have so far(I cropped out the unrelated parts): MainActivity public class MainActivity extends ActionBarActivity implements ListAdapter.OnShareClickedListener{ ListView main_list; List<String> url_list; @Override

Custom ListView adapter, strange ImageView behavior

会有一股神秘感。 提交于 2019-12-17 14:23:28
问题 I have a custom ListView Adapter , with which I'm creating rows for a list. My problem is though, that it doesn't seem to be distinguishing the ImageView s, from each other. It seems to be randomly picking ImageViews to chuck into place as I scroll up and down. The text information (omitted from this snippet) does not break. It works as one would expect. Here is the relevant method of my Adapter : public View getView( int position, View convertView, ViewGroup parent ) { View v = convertView;

Custom ListView adapter, strange ImageView behavior

限于喜欢 提交于 2019-12-17 14:23:18
问题 I have a custom ListView Adapter , with which I'm creating rows for a list. My problem is though, that it doesn't seem to be distinguishing the ImageView s, from each other. It seems to be randomly picking ImageViews to chuck into place as I scroll up and down. The text information (omitted from this snippet) does not break. It works as one would expect. Here is the relevant method of my Adapter : public View getView( int position, View convertView, ViewGroup parent ) { View v = convertView;

Cannot add header view to list — setAdapter has already been called

吃可爱长大的小学妹 提交于 2019-12-17 12:15:11
问题 I have one edittext field and one "search" button. When I click on search, I have to display a list view with data corresponding to the values entered in the edittext. I have added a header to my list using addHeader(). When I do search first time, I am able to display data in List successfully. But when I do search again, I am getting the below error. FATAL EXCEPTION: main java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called. at android.widget

Remove all items from RecyclerView

限于喜欢 提交于 2019-12-17 10:24:44
问题 I am trying to remove all the elements from my RecyclerView in my onRestart method so the items don't get loaded twice: @Override protected void onRestart() { super.onRestart(); // first clear the recycler view so items are not populated twice for (int i = 0; i < recyclerAdapter.getSize(); i++) { recyclerAdapter.delete(i); } // then reload the data PostCall doPostCall = new PostCall(); // my AsyncTask... doPostCall.execute(); } But for some reason the delete method I created in the adapter is

adapter-Any real example of Adapter Pattern

扶醉桌前 提交于 2019-12-17 10:10:10
问题 I want to demonstrate use of Adapter Pattern to my team. I've read many books and articles online. Everyone is citing an example which are useful to understand the concept (Shape, Memory Card, Electronic Adapter etc.), but there is no real case study. Can you please share any case study of Adapter Pattern? p.s. I tried searching existing questions on stackoverflow, but did not find the answer so posting it as a new question. If you know there's already an answer for this, then please redirect

Finding SSID of a wireless network with Java

孤者浪人 提交于 2019-12-17 04:32:55
问题 We're doing a project coded in Java (compiled for JRE 1.6) and need some help with a little but apparently complicated feature: We want to do a certain action when a specific wireless network is connected e.g. when the connected SSID=="myNetworkAtHome" or similar. After looking through this site, google and the Java documentation we have come a little closer. After looking at the code here: http://download.oracle.com/javase/tutorial/networking/nifs/retrieving.html It seems we were getting

Filtering ListView with custom (object) adapter

时光怂恿深爱的人放手 提交于 2019-12-17 02:09:13
问题 I'm trying to implement filtering of a ListView which is uses a custom object adapter, but I can't find any useful samples. The included code is very simplified, so no- keep in mind I can't use an regular ArrayAdapter. I have a EditText above the ListView, and when the user enters text in the EditText widget I would like to filter the ListView by the text written in the EditText. Any suggestions would be much appreciated! Here is the snippet from the activity class: public class management

Android--UI之Spinner

ε祈祈猫儿з 提交于 2019-12-17 00:51:19
前言   最近一直在讲AndroidUI的开发,今天讲一下Spinner控件,这是一个列表选择框,可以弹出一个列表供用户选择。在本片博客中,会讲解Spinner的基本属性以及设置之后的效果,以及使用SimpleAdapter绑定自定义格式的数据到Spinner中。 Spinner    Spinner 是一个列表选择框,会在用户选择后,展示一个列表供用户进行选择。Spinner是ViewGroup的间接子类,它和其他的Android控件一样,数据需要使用Adapter进行封装。   下面介绍一下Spinner的常用XML属性,Android也为其属性提供了相应的getter、setter方法: android:spinnerMode:列表显示的模式,有两个选择,为弹出列表(dialog)以及下拉列表(dropdown),如果不特别设置,为下拉列表。。 android:entries:使用<string-array.../>资源配置数据源。 android:prompt:对当前下拉列表设置标题,仅在dialog模式下有效。传递一个“@string/name”资源,需要在需要在资源文件中定义<string.../>。   作为一个列表选择控件,Spinner具有一些选中选项可以触发的事件,但它本身没有定义这些事件,均继承自间接父类 AdapterView