以编程方式为android布局充气
我希望一次又一次地重用现有布局,而不是创建/编写新的xml。现在,我已经喜欢上了 我希望以编程的方式实现这样的功能,而不是用xml编写(可能我希望用活动编写) 我可以知道怎么做吗?另外,另一个问题是,如果我这样重用,“id”将是相同的。如果是,如何设置文本以编程方式为android布局充气,android,xml,layout,layout-inflater,Android,Xml,Layout,Layout Inflater,我希望一次又一次地重用现有布局,而不是创建/编写新的xml。现在,我已经喜欢上了 我希望以编程的方式实现这样的功能,而不是用xml编写(可能我希望用活动编写) 我可以知道怎么做吗?另外,另一个问题是,如果我这样重用,“id”将是相同的。如果是,如何设置文本 将线性布局添加到布局中,然后以代码多次膨胀标题描述布局并将其添加到线性布局中 将布局更改为与此类似: <include layout="@layout/header_list_image"/> <LinearLayou
将线性布局添加到布局中,然后以代码多次膨胀标题描述布局并将其添加到线性布局中 将布局更改为与此类似:
<include layout="@layout/header_list_image"/>
<LinearLayout
android:layout_id="@+id/description_layout"
android:layout_width="match_parent"
android:layout_height="wrap_contents"
android:orientation="vertical" >
<include layout="@layout/header_url"/>
<include layout="@layout/row_listing_like_comment_share"/>
<include layout="@layout/header_comment_separator"/>
不是这样的:
findViewById(R.id.text_view);
descriptionLayout.findViewById(R.id.text_view);
findViewById(R.id.text_view);