手写android布局示例
package com.test;
import android.app.activity;
import android.os.bundle;
//import android.view.view;
import android.widget.button;
import android.widget.linearlayout;
//import android.widget.toast;
public class test_javaactivity extends activity {
@override
public void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
linearlayout layout = new linearlayout(this);
// layout.setorientation(linearlayout.vertical);
button button = new button(this);
button.settext("click me");
button.setlayoutparams(new linearlayout.layoutparams(
linearlayout.layoutparams.fill_parent,
linearlayout.layoutparams.wrap_content));
/** button.setonclicklistener(new view.onclicklistener() {
@override
public void onclick(view v) {
toast.maketext(test_javaactivity.this, "button clicked",
toast.length_long).show();
}
});
*/
layout.addview(button);
setcontentview(layout);
}
}
下一篇: Js 获取当前日期时间及其它操作实现代码
推荐阅读