zoukankan      html  css  js  c++  java
  • 利用在线工具自动化生成findviewById

    转自 https://www.cnblogs.com/tianzhijiexian/p/4458175.html

    我们在编码的时候经常会用到findviewById,不厌其烦,我之前介绍过一个很取巧的方法,挺好用的,这里再贴一下:

    复制代码
    public class KaleBaseActivity extends Activity {
    
        private String TAG = getClass().getSimpleName();
    
        public final <E extends View> E getView(int id) {
            try {
                return (E) findViewById(id);
            } catch (ClassCastException ex) {
                Log.e(TAG, "Could not cast View to concrete class.", ex);
                throw ex;
            }
        }
    }
    复制代码

    把这个写到activity的父类中,以后用getView就可以获得控件了。当然,如果你还是习惯findViewById,那么下面的两款工具绝对适合你。

    通过xml布局来生成findviewById的界面

    一、第一个简单好用的工具

    http://android.lineten.net/layout.php

    二、第二个稍微复杂,但功能强大的工具(推荐)

    https://www.buzzingandroid.com/tools/android-layout-finder/

  • 相关阅读:
    JS高级
    函数作用域面试题
    11.14
    11.13
    Redux知识
    react-router-dom
    react 的三大属性
    vuex
    数组的扩展
    函数作用域和 class
  • 原文地址:https://www.cnblogs.com/sheseido/p/14091106.html
Copyright © 2011-2022 走看看