您的位置:首页 > 其它

LinearLayout下添加一个item

2016-04-08 14:04 351 查看
方式一:

定义一个线性布局:

向线性布局增加一个item:

cardPhotoListView.addView(new CardItemView(this),cardPhotoListView.getChildCount()-1);
自定义的视图

public class CardItemView extends LinearLayout {
Button bt_delete;

public CardItemView(Context context) {
super(context);
LayoutInflater.from(context).inflate(R.layout.userspecificinfor3_item,
this);
}

public CardItemView(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.userspecificinfor3_item,
this);
}

}
方式二:

@ViewById(R.id.cardPhotoListView)LinearLayout cardPhotoListView;
@Click(R.id.addMaterial)
public void addMaterial() {
// TODO 动态增加一个线性布局
view = View.inflate(this, R.layout.userspecificinfor3_item, null);
cardPhotoListView.addView(view);
runUiThread();
}
@UiThread
public void runUiThread() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: