如何不用layout的xml文件添加控件??????? 有个现有的程序,想在页面里加一个进度条(ProgressBar),不知道不用findViewById()怎么加到页面中????(因为原程序layout里面没有xml文件,程序里面都是通过canvas()加东西) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 找到上一级view,然后创建Progressbar,然后调用一级view的AddChild,将Progressbar添加到上一级view中。 // 设置画面布局 ll = new LinearLayout(this.getBaseContext()); ll.setOrientation(LinearLayout.VERTICAL); // button mBtn = new Button(this.getBaseContext()); mBtn.setText("Draw"); // mBtn.setTextColor(0xff000000); mBtn.setTextSize(16); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.topMargin = 5; lp.leftMargin = 5; ll.addView(mBtn, lp); 参考buttonhttp://blog.csdn.net/ameyume/archive/2010/12/13/6074359.aspx so加载不了。 android底层学习 大神是怎么练成的? Webdav for android的包或者例子 如何在电脑中的ANDROID SDK中安装ICS stock browser并测试网页程序? android 中文文件名 显示乱码 bin下resource.ap_文件不生成了,怎么办? 貌似是Eclipse出问题了? 求解啊!!!!!!!!!!!!!!!!!!1 求Android画册制作思路! android 本地数据库 与远程数据库 同步 Fragment中ListView不显示 如何设置LinearLayout的长宽和位置??????? 数据库表中的记录删不掉也更新不了???
ll = new LinearLayout(this.getBaseContext());
ll.setOrientation(LinearLayout.VERTICAL);
// button
mBtn = new Button(this.getBaseContext());
mBtn.setText("Draw");
//
mBtn.setTextColor(0xff000000);
mBtn.setTextSize(16);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.topMargin = 5;
lp.leftMargin = 5;
ll.addView(mBtn, lp);
参考button
http://blog.csdn.net/ameyume/archive/2010/12/13/6074359.aspx