Android——动态加载布局
来源:互联网 发布:网络著名小说作家 编辑:程序博客网 时间:2024/05/22 00:33
动态加载其他布局的代码:
// 加载布局View show_note = View.inflate(Test_Note_Show.this,R.layout.note_show, null);// 设置动态布局的IDshow_note.setId(i);// 找到布局容器LinearLayout layout = (LinearLayout) findViewById(R.id.note_show_box);// 将布局加载到容器layout.addView(show_note);// 这里加入的Button是在delete_btn_box中另一个LinearLayout后面的View delete_btn = View.inflate(Test_Note_Show.this,R.layout.delete_btn, null);delete_btn.setId(10000 + i);LinearLayout layout_3 = (LinearLayout) findViewById(R.id.delete_btn_box);layout_3.addView(delete_btn);
note_show.xml:
<?xml version="1.0" encoding="UTF-8"?><LinearLayout android:orientation="vertical"xmlns:android="http://schemas.android.com/apk/res/android"android:layout_height="180dp" android:layout_width="match_parent"android:background="@drawable/note_frame_2"><LinearLayout android:id="@+id/delete_btn_box"android:layout_width="match_parent" android:layout_height="50dp"><!-- 就是在这个LinearLayout后面 --><LinearLayout android:layout_width="0dp"android:layout_height="match_parent" android:layout_weight="8.8"></LinearLayout></LinearLayout><LinearLayout android:layout_width="match_parent"android:layout_height="120dp" android:orientation="horizontal"><Button android:id="@+id/show_btn" android:layout_width="0dp"android:layout_height="match_parent" android:layout_weight="8.8"android:background="#00000000" /><Button android:id="@+id/edit_btn" android:layout_width="0dp"android:layout_height="match_parent" android:layout_weight="1.2"android:background="@drawable/feather_orange_opposite" /></LinearLayout></LinearLayout>
由此可见动态加载的顺序是首先加载静态布局,即.xml文件,然后再加载动态布局。
- Android——动态加载布局
- Android——动态加载资源布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- android 动态加载布局
- Android动态加载布局
- android动态加载布局
- ldconfig及其相关环境变量
- Nokia短信储存位置改变为储存卡后手机短信无法复制到卡里
- C# 窗体管理
- Android开发01——控件的使用,四则运算
- 在i386平台Linux 2.6 上实现一个系统调用
- Android——动态加载布局
- Winsock IO模型之Overlapped模型
- comzic scanner
- 【微创】求整数的二进制表示中有多少个1
- 用VC编程阻止全局钩子的加载.
- Linux core 文件介绍
- 看到的一个指针的问题。。。帮助复习了。。
- POJ 2499 求二叉树结点到根结点的路径长度 递归 二叉树
- 关于算法中的并查集,写的很有意思,转过来看看~