public class PostTextView extends TextView {

private Handler handler = new Handler(Looper.getMainLooper());

public PostTextView(Context context) {

super(context);

}

public PostTextView(Context context, AttributeSet attrs) {

super(context, attrs);

}

public PostTextView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

public boolean post(Runnable action) {

// FIXME: 2017/5/25 android 7.0以上post方法发生改变,导致点击事件无效

if(Build.VERSION.SDK_INT >= 24){

handler.post(action);

return true;

}

return super.post(action);

}

}

原文:http://www.cnblogs.com/wutianlong/p/6944040.html

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐