随笔分类 - android-widget
摘要:报错原因:使用Intent传递Bitmap等大数据,传递的parcel size超出了限制,binder事务报错了
阅读全文
摘要://Kotlin语法class TestActivity:Activity(){ private var touchEvent: MotionEvent? = null override fun dispatchTouchEvent(event: MotionEvent?): Boolean { if (event?.action == MotionEvent.ACTIO...
阅读全文
摘要:class MaxWidthLinearLayout @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : LinearLayout(context, attrs, defStyleAttr) { override fun onMeasure(width
阅读全文
摘要:RecyclerView嵌套RecyclerView点击Item时顶上去的原因是焦点抢占的原因,解决方法解决方法:holder.binding.rvContact.isFocusableInTouchMode = false (kotlin语法哦)注意:要在代码里面每次触发时设置,在xml里面一次性设置是无效的。
阅读全文
摘要:这是一个结合databinding写的用于RecyclerView的MultiTypeAdapter,写法和用法都非常简单高效,不需要再写ViewHolder了,不需要再写findViewById了,因为使用了databinding,真实项目使用的完整版,用上就会感受到其simple but powerful。github地址:https://github.com/yongfengnice/Re...
阅读全文
摘要:通用ViewHolder代码如下,就一个ViewHolder。。。从此不在是每个RecyclerView的Adapter编写一个ViewHolder了 class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { val binding = DataBindingUtil.bind(itemView)!!}gr...
阅读全文
摘要:网上的一大堆,都是有问题不完整的,互相copy。。。记录一下自己的解决方法。 另外附上menu的例子代码:res/menu/menu_tool_bar.xml java代码如下: val toolbar = findViewById(R.id.tool_bar)toolbar.inflateMenu(R.menu.menu_tool_bar)toolbar.setOnM...
阅读全文
摘要:NetworkImageView是一个异步请求图片然后再显示出来的ImageView,支持内存、磁盘缓存,支持gif。如果不想使用Glide、Picasso之类的图片框架,它是一个不错的图片自定义ImageView。github地址:https://github.com/yongfengnice/NetworkImageView
阅读全文
摘要:editText = findViewById(R.id.edit_text); editText.setFilters(new InputFilter[]{editText.getFilters()[0], mInputFilter}); //这里的editText.getFilters()[0]是为了保留上面的xml设置的LengthFilter同时有效 InputFilter mIn...
阅读全文
摘要:@Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { getDialog().getWindow().setBackgroundDrawable(...
阅读全文
摘要://java代码: public class CountrySelectDialog extends AppCompatDialogFragment{ public static CountrySelectDialog newInstance() { Bundle args = new Bundle(); CountrySelectDialog fragment = new...
阅读全文
摘要:使用AppCompatDialogFragment 或者 DialogFragment 的过程中遇到java.lang.IllegalStateException: Fragment already added: 的解决方法:
阅读全文