代码编写布局
来源:互联网 发布:数据缺失的解决方法 编辑:程序博客网 时间:2024/05/21 22:24
以前没有用代码写个布局文件,今天尝试了下,
很不熟悉,不过总算搞定,做笔记以防忘记!
package com.login.login.widget;import com.login.login.R;import android.app.Activity;import android.os.Bundle;import android.widget.ArrayAdapter;import android.widget.LinearLayout;import android.widget.ScrollView;import android.widget.Spinner;public class SpinnerTestActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);// setContentView(R.layout.spinnertest);ScrollView scrollView = new ScrollView(this);LinearLayout l = new LinearLayout(this);l.setOrientation(LinearLayout.VERTICAL);scrollView.addView(l);int textViewResourceId = android.R.layout.simple_spinner_item;creatspinner(textViewResourceId, l);int textViewResourceId2 = android.R.layout.browser_link_context_header;creatspinner(textViewResourceId2, l);int textViewResourceId3 = android.R.layout.preference_category;creatspinner(textViewResourceId3, l);int textViewResourceId4 = android.R.layout.select_dialog_item;creatspinner(textViewResourceId4, l);int textViewResourceId5 = android.R.layout.select_dialog_multichoice;creatspinner(textViewResourceId5, l);int textViewResourceId6 = android.R.layout.select_dialog_singlechoice;creatspinner(textViewResourceId6, l);int textViewResourceId7 = android.R.layout.simple_dropdown_item_1line;creatspinner(textViewResourceId7, l);int textViewResourceId8 = android.R.layout.simple_expandable_list_item_1;creatspinner(textViewResourceId8, l);int textViewResourceId9 = android.R.layout.simple_gallery_item;creatspinner(textViewResourceId9, l);int textViewResourceId10 = android.R.layout.simple_list_item_1;creatspinner(textViewResourceId10, l);int textViewResourceId11 = android.R.layout.simple_list_item_checked;creatspinner(textViewResourceId11, l);int textViewResourceId12 = android.R.layout.simple_list_item_multiple_choice;creatspinner(textViewResourceId12, l);int textViewResourceId13 = android.R.layout.simple_list_item_single_choice;creatspinner(textViewResourceId13, l);int textViewResourceId14 = android.R.layout.simple_spinner_dropdown_item;creatspinner(textViewResourceId14, l);int textViewResourceId15 = android.R.layout.simple_spinner_item;creatspinner(textViewResourceId15, l);int textViewResourceId16 = android.R.layout.test_list_item;creatspinner(textViewResourceId16, l);setContentView(scrollView);}private void creatspinner(int style_layout, LinearLayout l) {Spinner sp = new Spinner(this);ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, style_layout);adapter.add("red");adapter.add("green");adapter.add("yellow");adapter.add("black");adapter.add("write");adapter.add("blue");adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);sp.setAdapter(adapter);LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);l.addView(sp, ll);//setContentView(l);}}
0 0
- 代码编写布局
- android使用代码编写布局
- android 用代码编写linearlayout布局
- android代码编写布局和控件
- xcode 中的代码编写自适应布局
- android 用代码编写linearlayout布局
- android 纯代码 详细编写布局文件
- Android中怎么用纯代码编写布局?
- Android笔记:代码编写布局控制显示位置
- iOS编程 界面布局 纯代码 VFL编写和添加
- 代码编写布局的顺序的一点疑惑
- 代码布局
- 代码布局
- 代码布局
- 编写代码
- 代码编写
- 代码编写
- 代码编写
- ListView工作原理
- ubuntu.sh: 118: ubuntu.sh: Syntax error: "(" unexpected
- javascript焦点图(可以自动切换 )
- 引用NPOI动态创建EXCEL表
- 修复低版本Tomcat重新装了新版本TomCat版本后出现的错误
- 代码编写布局
- Sqoop-1.4.4工具import和export使用详解
- 我自己常用的eclipse 快捷键整理
- DNSAMD撒旦撒
- MyEclipse10修改User default location
- 13年很多客户推广淘宝淘宝客站推广技巧视频教程COM “TARGET = ” _bla
- 如何让搜索引擎收录文章
- cocos2d-x 音效中断问题
- <div class="clear"></div>