1.在布局内使用其它控件

1.1 效果

  箭头所指3个控件的内容随输入框内容而变化。

1.2 示例代码

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layout xmlns:app="http://schemas.android.com/apk/res-auto"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. xmlns:android="http://schemas.android.com/apk/res/android">
  5. <data>
  6. <import type="android.view.View" />
  7. <import type="com.example.databind.Exts" />
  8. </data>
  9. <androidx.constraintlayout.widget.ConstraintLayout
  10. android:clickable="true"
  11. android:background="#ffffff"
  12. android:layout_width="match_parent"
  13. android:layout_height="match_parent">
  14.  
  15. <TextView
  16. android:id="@+id/features_title"
  17. android:layout_width="wrap_content"
  18. android:layout_height="wrap_content"
  19. android:layout_marginTop="16dp"
  20. android:text="binding features"
  21. android:textAllCaps="false"
  22. app:layout_constraintEnd_toEndOf="parent"
  23. app:layout_constraintStart_toStartOf="parent"
  24. app:layout_constraintTop_toTopOf="parent" />
  25.  
  26. <TextView
  27. android:id="@+id/features_txt1"
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:layout_marginTop="48dp"
  31. android:background="#f8f8f8"
  32. android:textSize="12sp"
  33. android:text='@{featureEdt.text.toString(),default="取 feature_edt 的值"}'
  34. app:layout_constraintEnd_toStartOf="@+id/features_txt2"
  35. app:layout_constraintStart_toStartOf="parent"
  36. app:layout_constraintTop_toBottomOf="@+id/feature_edt" />
  37.  
  38. <TextView
  39. android:id="@+id/features_txt2"
  40. android:layout_width="wrap_content"
  41. android:layout_height="wrap_content"
  42. android:background="#f8f8f8"
  43. android:textSize="12sp"
  44. android:text='@{featureEdt.text.toString(),default="取 feature_edt 的值"}'
  45. app:layout_constraintBottom_toBottomOf="@+id/features_txt1"
  46. app:layout_constraintEnd_toEndOf="parent"
  47. app:layout_constraintStart_toEndOf="@+id/features_txt1"
  48. app:layout_constraintTop_toTopOf="@+id/features_txt1" />
  49. <!--android:textColor="@{featureEdt.text.hasCharX('e') ? @color/colorAccent : @color/colorPrimaryDark }"-->
  50.  
  51. <EditText
  52. android:id="@+id/feature_edt"
  53. android:layout_width="0dp"
  54. android:layout_height="64dp"
  55. android:layout_marginStart="16dp"
  56. android:layout_marginLeft="16dp"
  57. android:layout_marginTop="32dp"
  58. android:layout_marginEnd="16dp"
  59. android:layout_marginRight="16dp"
  60. android:background="@drawable/edt_bg"
  61. android:ems=""
  62. android:textColor='@{featureEdt.text.toString().length() > 8 ? @color/colorAccent : @color/colorPrimaryDark }'
  63. android:inputType="textPersonName"
  64. android:paddingLeft="8dp"
  65. android:text="Name"
  66. android:maxLength=""
  67. android:maxLines=""
  68. android:textAllCaps="false"
  69. android:textSize="12sp"
  70. app:layout_constraintEnd_toEndOf="parent"
  71. app:layout_constraintStart_toStartOf="parent"
  72. app:layout_constraintTop_toBottomOf="@+id/features_title" />
  73.  
  74. <TextView
  75. android:id="@+id/toast"
  76. android:layout_width="wrap_content"
  77. android:layout_height="wrap_content"
  78. android:textSize="9sp"
  79. android:textColor='@{featureEdt.text.toString().length() &lt; 1 ? @color/colorAccent : @color/colorPrimaryDark,default=@color/colorPrimary}'
  80. android:text='@{featureEdt.text.toString().length() &lt; 1 ? "不能为空" :"1-16个字符",default = "1-16个字符"}'
  81. app:layout_constraintStart_toStartOf="@+id/feature_edt"
  82. app:layout_constraintTop_toBottomOf="@+id/feature_edt" />
  83.  
  84. </androidx.constraintlayout.widget.ConstraintLayout>
  85. </layout>

1.3 特性描述

  • 控件按驼峰式命名法命名,如 :   feature_edt   ->   featureEdt
  • 其它控件可以在布局内访问这个控件以及它的成员,第34、45、81行。
  • 不可以调用控件的扩展成员。第50行。
  • 控件自己可以调用自己,第63行。

2. 可以使用格式化字符串

  • 示例,@string/xxx 可以和 “字符串” 相加 ,如下

    1. <TextView
    2. android:id="@+id/tvFormat"
    3. android:layout_width="wrap_content"
    4. android:layout_height="wrap_content"
    5. android:layout_marginTop="24dp"
    6. android:text='@{@string/format("李4",0x20,33.333333f) + " string/xxx 可以和 字符串相加 ",default=@string/format}'
    7. app:layout_constraintStart_toStartOf="@+id/feature_edt"
    8. app:layout_constraintTop_toBottomOf="@+id/features_txt1" />
  • string.xml

    1. <resources>
    2. <string name="app_name">DataBind</string>
    3. <string name="format">format : name=%1$s,age=%2$1d,value=%3$32f </string>
    4. //...
    5. </resources>

     

3.对象传递到include布局中

3.1 示例

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. xmlns:bind="http://schemas.android.com/apk/res-auto">
  6. <data>
  7. <variable name="data" type="com.example.databind.Data" />
  8. <variable name="click" type="com.example.databind.Click" />
  9. </data>
  10.  
  11. <androidx.constraintlayout.widget.ConstraintLayout
  12. android:layout_width="match_parent"
  13. android:layout_height="match_parent"
  14. android:clickable="true"
  15. android:focusable="true"
  16. android:focusableInTouchMode="true"
  17. android:onClick="@{click::onStartClicked}">
  18.  
  19. //...
  20.  
  21. <include
  22. android:id="@+id/include"
  23. layout="@layout/include"
  24. android:layout_width="0dp"
  25. android:layout_height="wrap_content"
  26. android:layout_marginTop="16dp"
  27. app:layout_constraintEnd_toEndOf="@+id/frgmt2"
  28. app:layout_constraintStart_toStartOf="@+id/frgmt2"
  29. app:layout_constraintTop_toBottomOf="@+id/frgmt2"
  30. bind:data="@{data}"
  31. bind:title='@{"标题"}'
  32. />
  33. ...

  代码中把 data 传递给 @layout/include ,要求这个布局也使用数据绑定布局,且也声明data和title变量。

如下:

  1. <layout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:app="http://schemas.android.com/apk/res-auto">
  3.  
  4. <data>
  5. <variable name="data" type="com.example.databind.Data" />
  6. <variable name="title" type="String" />
  7. </data>
  8.  
  9. <androidx.constraintlayout.widget.ConstraintLayout
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:background="#7ff77ff7"
  13. >
  14.  
  15. //...
  16.  
  17. <TextView
  18. android:id="@+id/value"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:layout_marginStart="32dp"
  22. android:layout_marginLeft="32dp"
  23. android:text="@{String.valueOf(data.value),default = value}"
  24. app:layout_constraintEnd_toEndOf="parent"
  25. app:layout_constraintStart_toEndOf="@+id/key"
  26. app:layout_constraintTop_toTopOf="@+id/key" />
  27.  
  28. </androidx.constraintlayout.widget.ConstraintLayout>
  29. </layout>

3.2 不支持 merge 为直接子元素

数据绑定不支持 include 作为 merge 元素的直接子元素

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:bind="http://schemas.android.com/apk/res-auto">
  4. <data>
  5. <variable name="user" type="com.example.User"/>
  6. </data>
  7. <merge><!-- Doesn't work -->
  8. <include layout="@layout/name"
  9. bind:user="@{user}"/>
  10. <include layout="@layout/contact"
  11. bind:user="@{user}"/>
  12. </merge>
  13. </layout>

#.后台线程的疑惑

#.1 问题

英文原版

中文版 

#.2 疑惑?

  Collection<T> 实现类 里存放的数据,不能在后台线程中修改?

#.3 测试代码

  在后台线程中对list 操作,并没有发现问题

  1. package com.example.databind
  2.  
  3. import android.os.Bundle
  4. import android.view.LayoutInflater
  5. import android.view.View
  6. import android.view.ViewGroup
  7. import androidx.databinding.ObservableField
  8. import androidx.fragment.app.Fragment
  9. import com.example.databind.databinding.MapCollectionBinding
  10. import kotlin.concurrent.thread
  11.  
  12. class MapCollectionFrgmt : Fragment() {
  13.  
  14. lateinit var binding : MapCollectionBinding
  15.  
  16. val list = ArrayList<String>()
  17. val map = HashMap<String,ObservableField<String>>()
  18. val data = Data()
  19.  
  20. init {
  21. data.key = "data key"
  22. data.key = "data value"
  23.  
  24. map.put("key1",ObservableField("value1"))
  25. map.put("key2",ObservableField("value2"))
  26. map.put("key3",ObservableField("value3"))
  27. map.put("key4",ObservableField("value4"))
  28.  
  29. list.add("value0")
  30. list.add("value1")
  31. list.add("value2")
  32. list.add("value3")
  33. }
  34.  
  35. fun onDataThreadMainClicked(view: View){
  36. val random = (Math.random() * ).toInt()
  37. data.key = "新Main key$random"
  38. data.value = random
  39. binding.data = data
  40. }
  41.  
  42. fun onDataThreadOtherClicked(view: View){
  43. thread {
  44. val random = (Math.random() * ).toInt()
  45. data.key = "新other key$random"
  46. data.value = random
  47. binding.data = data
  48. }
  49. }
  50.  
  51. fun onMap1ThreadMain(v : View){
  52. val random = (Math.random() * ).toInt()
  53. val ob = ObservableField<String>()
  54. ob.set("新Main value$random")
  55. map.put("key1",ob)
  56. binding.map = map
  57. }
  58. fun onMap1ThreadOther(v : View){
  59. thread {
  60. val random = (Math.random() * ).toInt()
  61. val ob = ObservableField<String>()
  62. ob.set("新Main value$random")
  63. map.put("key1",ob)
  64. binding.map = map
  65. }
  66. }
  67. fun onList0ThreadMain(v : View){
  68. val random = (Math.random() * ).toInt()
  69. list[] = "新Main value$random"
  70. binding.list = list
  71. }
  72. fun onList0ThreadOther(v : View){
  73. thread {
  74. val random = (Math.random() * ).toInt()
  75. list[] = "新Main value$random"
  76. binding.list = list
  77. }
  78. }
  79. fun initBinding(){
  80. binding.list = list
  81. binding.data = data
  82. binding.map = map
  83.  
  84. binding.threadMainData.setOnClickListener(this::onDataThreadMainClicked)
  85. binding.threadOtherData.setOnClickListener(this::onDataThreadOtherClicked)
  86. binding.threadMainMap1.setOnClickListener(this::onMap1ThreadMain)
  87. binding.threadOtherMap1.setOnClickListener(this::onMap1ThreadOther)
  88. binding.threadMainList0.setOnClickListener(this::onList0ThreadMain)
  89. binding.threadOtherList0.setOnClickListener(this::onList0ThreadOther)
  90. /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  91. val text: String = getString(R.string.map_title, map.size)
  92. val styledText: Spanned = Html.fromHtml(text, FROM_HTML_OPTION_USE_CSS_COLORS)
  93. binding.mapTitle.text = styledText
  94. }*/
  95. }
  96.  
  97. override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  98. binding = MapCollectionBinding.inflate(inflater,container,false)
  99. initBinding()
  100. return binding.root
  101. }
  102.  
  103. override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  104. super.onViewCreated(view, savedInstanceState)
  105. }
  106.  
  107. override fun onDetach() {
  108. super.onDetach()
  109. }
  110.  
  111. }

布局

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layout xmlns:app="http://schemas.android.com/apk/res-auto"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. xmlns:android="http://schemas.android.com/apk/res/android">
  5. <data >
  6. <import type="androidx.databinding.ObservableField" />
  7. <variable name="data" type="com.example.databind.Data" />
  8. <variable name="map" type="java.util.HashMap&lt;String,ObservableField&lt;String>>" />
  9. <variable name="list" type="java.util.List&lt;String>" />
  10. </data>
  11. <androidx.constraintlayout.widget.ConstraintLayout
  12. android:clickable="true"
  13. android:background="#ffffff"
  14. android:layout_width="match_parent"
  15. android:layout_height="match_parent">
  16.  
  17. <TextView
  18. android:id="@+id/data_title"
  19. android:layout_width="0dp"
  20. android:layout_height="wrap_content"
  21. android:layout_marginTop="16dp"
  22. android:background="#f6f6f6"
  23. android:paddingLeft="16dp"
  24. android:text="data "
  25. app:layout_constraintEnd_toEndOf="parent"
  26. app:layout_constraintStart_toStartOf="parent"
  27. app:layout_constraintTop_toTopOf="parent" />
  28.  
  29. <TextView
  30. android:id="@+id/map_title"
  31. android:layout_width="0dp"
  32. android:layout_height="wrap_content"
  33. android:layout_marginTop="16dp"
  34. android:background="#f8f8f8"
  35. android:paddingLeft="16dp"
  36. android:text="@{@string/map_title(map.size()) ,default=@string/map_title}"
  37. app:layout_constraintEnd_toEndOf="parent"
  38. app:layout_constraintStart_toStartOf="parent"
  39. app:layout_constraintTop_toBottomOf="@+id/data_key" />
  40.  
  41. <TextView
  42. android:id="@+id/data_key"
  43. android:layout_width="wrap_content"
  44. android:layout_height="wrap_content"
  45. android:layout_marginStart="32dp"
  46. android:layout_marginLeft="32dp"
  47. android:layout_marginTop="16dp"
  48. android:text='@{data.key}'
  49. app:layout_constraintStart_toStartOf="@+id/data_title"
  50. app:layout_constraintTop_toBottomOf="@+id/data_title" />
  51.  
  52. <TextView
  53. android:id="@+id/data_value"
  54. android:layout_width="wrap_content"
  55. android:layout_height="wrap_content"
  56. android:layout_marginStart="16dp"
  57. android:layout_marginLeft="16dp"
  58. android:text='@{String.valueOf(data.value)}'
  59. app:layout_constraintStart_toEndOf="@+id/data_key"
  60. app:layout_constraintTop_toTopOf="@+id/data_key" />
  61.  
  62. <TextView
  63. android:id="@+id/map_key1"
  64. android:layout_width="wrap_content"
  65. android:layout_height="wrap_content"
  66. android:layout_marginStart="24dp"
  67. android:layout_marginLeft="24dp"
  68. android:layout_marginTop="16dp"
  69. android:text='@{@string/map_key_value("key1",map["key1"]),default=@string/map_key_value}'
  70. app:layout_constraintStart_toStartOf="parent"
  71. app:layout_constraintTop_toBottomOf="@+id/map_title" />
  72.  
  73. <TextView
  74. android:id="@+id/map_key3"
  75. android:layout_width="wrap_content"
  76. android:layout_height="wrap_content"
  77. android:layout_marginTop="8dp"
  78. android:text='@{@string/map_key_value("key1",map["key3"]),default=@string/map_key_value}'
  79. app:layout_constraintStart_toStartOf="@+id/map_key1"
  80. app:layout_constraintTop_toBottomOf="@+id/map_key2" />
  81.  
  82. <TextView
  83. android:id="@+id/map_key4"
  84. android:layout_width="wrap_content"
  85. android:layout_height="wrap_content"
  86. android:layout_marginTop="8dp"
  87. android:text='@{@string/map_key_value("无效key",map["无效key"]),default=@string/map_key_value}'
  88. app:layout_constraintStart_toStartOf="@+id/map_key2"
  89. app:layout_constraintTop_toBottomOf="@+id/map_key3" />
  90.  
  91. <TextView
  92. android:id="@+id/map_key2"
  93. android:layout_width="wrap_content"
  94. android:layout_height="wrap_content"
  95. android:layout_marginTop="8dp"
  96. android:text='@{@string/map_key_value("key2",map["key2"]),default=@string/map_key_value}'
  97. app:layout_constraintStart_toStartOf="@+id/map_key1"
  98. app:layout_constraintTop_toBottomOf="@+id/map_key1" />
  99.  
  100. <TextView
  101. android:id="@+id/list_title"
  102. android:layout_width="0dp"
  103. android:layout_height="wrap_content"
  104. android:layout_marginTop="24dp"
  105. android:background="#f8f8f8"
  106. android:paddingLeft="16dp"
  107. android:text="@{@string/list_title(list.size()) ,default=@string/list_title}"
  108. app:layout_constraintEnd_toEndOf="parent"
  109. app:layout_constraintStart_toStartOf="parent"
  110. app:layout_constraintTop_toBottomOf="@+id/map_key4" />
  111.  
  112. <TextView
  113. android:id="@+id/list_0"
  114. android:layout_width="wrap_content"
  115. android:layout_height="wrap_content"
  116. android:layout_marginStart="24dp"
  117. android:layout_marginLeft="24dp"
  118. android:layout_marginTop="16dp"
  119. android:text='@{@string/list_index(0,list[0]),default=@string/list_index}'
  120. app:layout_constraintStart_toStartOf="parent"
  121. app:layout_constraintTop_toBottomOf="@+id/list_title" />
  122.  
  123. <TextView
  124. android:id="@+id/list_1"
  125. android:layout_width="wrap_content"
  126. android:layout_height="wrap_content"
  127. android:layout_marginTop="8dp"
  128. android:text='@{@string/list_index(1,list[1]),default=@string/list_index}'
  129. app:layout_constraintStart_toStartOf="@+id/list_0"
  130. app:layout_constraintTop_toBottomOf="@+id/list_0" />
  131.  
  132. <TextView
  133. android:id="@+id/list_2"
  134. android:layout_width="wrap_content"
  135. android:layout_height="wrap_content"
  136. android:layout_marginTop="8dp"
  137. android:text='@{@string/list_index(2,list[2]),default=@string/list_index}'
  138. app:layout_constraintStart_toStartOf="@+id/list_1"
  139. app:layout_constraintTop_toBottomOf="@+id/list_1" />
  140.  
  141. <TextView
  142. android:id="@+id/list_3"
  143. android:layout_width="104dp"
  144. android:layout_height="15dp"
  145. android:layout_marginTop="8dp"
  146. android:text='@{@string/list_index(-1,list[-1]) ,default=@string/list_index}'
  147. app:layout_constraintStart_toStartOf="@+id/list_2"
  148. app:layout_constraintTop_toBottomOf="@+id/list_2" />
  149.  
  150. <TextView
  151. android:id="@+id/thread_title"
  152. android:layout_width="0dp"
  153. android:layout_height="wrap_content"
  154. android:layout_marginTop="32dp"
  155. android:background="#f8f8f8"
  156. android:paddingLeft="16dp"
  157. android:text="在线程中修改数据"
  158. app:layout_constraintEnd_toEndOf="parent"
  159. app:layout_constraintStart_toStartOf="parent"
  160. app:layout_constraintTop_toBottomOf="@+id/list_3" />
  161.  
  162. <Button
  163. android:id="@+id/thread_main_data"
  164. android:layout_width="wrap_content"
  165. android:layout_height="wrap_content"
  166. android:layout_marginTop="16dp"
  167. android:text="主线程修改data"
  168. android:textAllCaps="false"
  169. app:layout_constraintEnd_toStartOf="@+id/thread_other_data"
  170. app:layout_constraintStart_toStartOf="parent"
  171. app:layout_constraintTop_toBottomOf="@+id/thread_title" />
  172.  
  173. <Button
  174. android:id="@+id/thread_other_data"
  175. android:layout_width="wrap_content"
  176. android:layout_height="wrap_content"
  177. android:layout_marginTop="16dp"
  178. android:text="非主线程修改data"
  179. android:textAllCaps="false"
  180. app:layout_constraintEnd_toEndOf="parent"
  181. app:layout_constraintStart_toEndOf="@+id/thread_main_data"
  182. app:layout_constraintTop_toBottomOf="@+id/thread_title" />
  183.  
  184. <Button
  185. android:id="@+id/thread_main_list0"
  186. android:layout_width="wrap_content"
  187. android:layout_height="wrap_content"
  188. android:layout_marginTop="16dp"
  189. android:text="主线程修改list[0]"
  190. android:textAllCaps="false"
  191. app:layout_constraintEnd_toStartOf="@+id/thread_other_list0"
  192. app:layout_constraintStart_toStartOf="parent"
  193. app:layout_constraintTop_toBottomOf="@+id/thread_main_data" />
  194.  
  195. <Button
  196. android:id="@+id/thread_other_list0"
  197. android:layout_width="wrap_content"
  198. android:layout_height="wrap_content"
  199. android:layout_marginTop="16dp"
  200. android:text="非主线程修改list[0]"
  201. android:textAllCaps="false"
  202. app:layout_constraintEnd_toEndOf="parent"
  203. app:layout_constraintStart_toEndOf="@+id/thread_main_list0"
  204. app:layout_constraintTop_toBottomOf="@+id/thread_main_data" />
  205.  
  206. <Button
  207. android:id="@+id/thread_main_map1"
  208. android:layout_width="wrap_content"
  209. android:layout_height="wrap_content"
  210. android:layout_marginTop="16dp"
  211. android:text="主线程修改map[key1]"
  212. android:textAllCaps="false"
  213. app:layout_constraintEnd_toStartOf="@+id/thread_other_map1"
  214. app:layout_constraintStart_toStartOf="parent"
  215. app:layout_constraintTop_toBottomOf="@+id/thread_main_list0" />
  216.  
  217. <Button
  218. android:id="@+id/thread_other_map1"
  219. android:layout_width="wrap_content"
  220. android:layout_height="wrap_content"
  221. android:layout_marginTop="16dp"
  222. android:text="非主线程修改map[key1]"
  223. android:textAllCaps="false"
  224. app:layout_constraintEnd_toEndOf="parent"
  225. app:layout_constraintStart_toEndOf="@+id/thread_main_map1"
  226. app:layout_constraintTop_toBottomOf="@+id/thread_main_list0" />
  227.  
  228. </androidx.constraintlayout.widget.ConstraintLayout>
  229. </layout>

#.4 viewModel 放在集合里?

  布局文件中通过viewModel访问数据,然后viewModel放在集合里?还会这么用?不解。

android 数据绑定(4)实用特性及疑惑:使用控件、格式化@string/xxx、对象传递、双向数据绑定的更多相关文章

  1. Android 打造完美的侧滑菜单/侧滑View控件

    概述 Android 打造完美的侧滑菜单/侧滑View控件,完全自定义实现,支持左右两个方向弹出,代码高度简洁流畅,兼容性高,控件实用方便. 详细 代码下载:http://www.demodashi. ...

  2. ANDROID L——Material Design详解(UI控件)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...

  3. Android判断Touch为滑动事件还是操作控件

    Android判断Touch为滑动事件还是操作控件 因为在项目中要判断WebView是否处于滚动状态,但它不像ListView有onScrollStateChanged方法来监听,要实现就得手动监听它 ...

  4. 怎样在Android实现桌面清理内存简单Widget小控件

    怎样在Android实现桌面清理内存简单Widget小控件 我们常常会看到类似于360.金山手机卫士一类的软件会带一个widget小控件,显示在桌面上,上面会显示现有内存大小,然后会带一个按键功能来一 ...

  5. Android 自定义支持快速搜索筛选的选择控件(一)

    Android 自定义支持快速搜索筛选的选择控件 项目中遇到选择控件选项过多,需要快速查找匹配的情况. 做了简单的Demo,效果图如下: 源码地址:https://github.com/whieenz ...

  6. 背水一战 Windows 10 (50) - 控件(集合类): ItemsControl - 基础知识, 数据绑定, ItemsPresenter, GridViewItemPresenter, ListViewItemPresenter

    [源码下载] 背水一战 Windows 10 (50) - 控件(集合类): ItemsControl - 基础知识, 数据绑定, ItemsPresenter, GridViewItemPresen ...

  7. (转载) Android RecyclerView 使用完全解析 体验艺术般的控件

    Android RecyclerView 使用完全解析 体验艺术般的控件 标签: Recyclerviewpager瀑布流 2015-04-16 09:07 721474人阅读 评论(458) 收藏  ...

  8. Android自定义View(三、深入解析控件测量onMeasure)

    转载请标明出处: http://blog.csdn.net/xmxkf/article/details/51490283 本文出自:[openXu的博客] 目录: onMeasure什么时候会被调用 ...

  9. android内部培训视频_第三节 常用控件(Button,TextView,EditText,AutocompleteTextView)

    第三节:常用控件 一.Button 需要掌握的属性: 1.可切换的背景 2.9.png使用 3.按钮点击事件 1)  onClick 3) 匿名类 4) 公共类 二.TextView 常用属性 1.a ...

随机推荐

  1. 使用IDEA生成jar包的步骤(IDEA打jar包)

    第一步: 1.把module目录下的MATA-INF文件夹删除,如果没有MATA-INF文件夹则不用删除 2.Ctrl + Alt + Shift + S 打开 Project Structure 窗 ...

  2. Linux学习笔记之如何在图形界面旁边把终端添加显示出来

    首先旁边无终端,我们可以点击ctrl+alt+t,可以把终端显示出来 右键点击终端,然后点击Lock to Launcher,然后完成 PS:不想显示也可以点击其右键,选择Unlock from La ...

  3. 剑指offer之字符串是否为数值

    1. 题目 这是<剑指offer>上的一道题,刚开始觉得这是一道挺简单的题目,后来发现自己太年轻了,考虑的因素太少了,思考了而是分钟还是无从下手,看了作者的思路深深被他折服了,题目如下: ...

  4. ALGEBRA-前言

    “当你读一页不到一个小时的话,可能是你读太快了” 哈哈 可以 慢慢品

  5. C#LeetCode刷题-拒绝采样

    拒绝采样篇 # 题名   通过率 难度 470 用 Rand7() 实现 Rand10()   34.4% 中等 478 在圆内随机生成点   22.8% 中等

  6. C#LeetCode刷题-蓄水池抽样

    蓄水池抽样篇 # 题名 刷题 通过率 难度 382 链表随机节点   47.0% 中等 398 随机数索引   41.6% 中等

  7. three.js 制作机房(上)

    three.js使用的人太少了,一个博文就几百个人看,之前发js基础哪怕是d3都会有几千的阅读量,看看以后考虑说一说d3了,哈哈.吐槽完毕回归正题.前几天郭先生看到网上有人开发了3D机房,正愁博客没什 ...

  8. [算法入门]——深度优先搜索(DFS)

    深度优先搜索(DFS) 深度优先搜索叫DFS(Depth First Search).OK,那么什么是深度优先搜索呢?_? 样例: 举个例子,你在一个方格网络中,可以简单理解为我们的地图,要从A点到B ...

  9. run as --> Maven clean 可以清除旧的jar包

    run as --> Maven clean 可以清除旧的jar包

  10. 【WC2013】 糖果公园 - 树上莫队

    问题描述 Candyland 有一座糖果公园,公园里不仅有美丽的风景.好玩的游乐项目,还有许多免费糖果的发放点,这引来了许多贪吃的小朋友来糖果公园游玩.糖果公园的结构十分奇特,它由 n 个游览点构成, ...