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);
}
定义一个线性布局:
向线性布局增加一个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);
}
相关文章推荐
- WriteFileSession_usrname.php
- Batch Normalization 学习笔记
- DFS+dp 51Nod1448 等幂映射
- 开博通知
- 在C中使用LuaJit FFI
- iOS中的数据存储方式_Plist
- Object-C 工厂方法
- mysql数据库cpu、mem使用率高的解决案例
- 实现tftp文件互传的最小局域网设置
- Ubuntu 14.04 下安装svn服务器,同步更新web服务器
- nmap#2探测网关
- Could not open Hibernate Session for transaction; nested exception is.....远程服务器部署后出现这个问题分析
- JAVA---Merge Intervals
- 详解linux下的串口通讯开发
- MAT内存分析工具的使用
- Qt QLineEdit 限制输入类型以及大小Int 和double
- 回顾
- 内存管理
- [调整] Firemonkey TEdit 避免按下立即弹出键盘的问题
- Android之Fragment(一)