Android ids.xml 的作用

    技术2022-07-14  105

    ids概述

    ids.xml:为应用的相关资源提供唯一的资源id。id是为了获得xml中的对象需要的参数,也就是 Object = findViewById(R.id.id_name); 中的id_name。

    使用

    例如xml中定义如下

    <resources> <item type="id" name="btn_next" /> </resources>

    xml中使用id

    <Button android:id="@id/btn_next" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="next"/>

    java使用id

    Button button = new Button(this); button.setId(R.id.btn_next);

     

    Processed: 0.008, SQL: 9