在LinearLayout裡動態新增子佈局
阿新 • • 發佈:2019-02-01
-
//初始化佈局
-
LinearLayout mContentLayout = (LinearLayout) findViewById(R.id.lin_control);
-
//迴圈新增資料
-
private void setTextShopingView() {
-
mContentLayout.removeAllViews();
-
if (Info.getData() != null && Info.getData().size() > 0) {
-
LinearLayout childLayout= (LinearLayout)mLayoutInflater.inflate(
-
R.layout.child_layout, null);
-
ImageView mImge= (ImageView) childLayout
-
.findViewById(R.id.image);
-
TextView mText= (TextView) childLayout
-
.findViewById(R.id.txt);
-
mContentLayout.addView(childLayout);
-
mContentLayout.setVisibility(View.VISIBLE);
-
} else {
-
mContentLayout.setVisibility(View.GONE);
-
}
-
}