做网站购买服务器吗,网站建设财务分析,品牌建设题目,长春seo整站优化我们很多时候会对某些View设置点击事件#xff0c;但是#xff0c;当对这个View同时设置了focusableInTouchModetrue时#xff0c;第一次点击事件会被消费为为此View获取焦点。
Viewandroid:idid/v_clickandroid:layout_widthmatch_parentandr…我们很多时候会对某些View设置点击事件但是当对这个View同时设置了focusableInTouchModetrue时第一次点击事件会被消费为为此View获取焦点。
Viewandroid:idid/v_clickandroid:layout_widthmatch_parentandroid:layout_height200dpandroid:focusableInTouchModetrueandroid:backgroundcolor/cardview_dark_background/创建一个View并同时指定了 android:focusableInTouchModetrue在Activity代码中对View设置点击事件。
var count 0findViewByIdView(R.id.v_click)?.let {it.setOnFocusChangeListener { v, hasFocus - Log.e(V_CLICK, hasFocus ${hasFocus}) }it.setOnClickListener {Log.e(V_CLICK, click ${count})}}发现第一次点击LogCat显示
V_CLICK E hasFocus true再次点击才出现点击事件的Log
V_CLICK E click 1