手写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);
}
}
上一篇:解析android中的帮助、about、关于作者、HELP等提示页面
栏 目:Android代码
下一篇:Android重写TextView实现文字整齐排版的方法(附demo源码下载)
本文标题:手写android布局示例
本文地址:http://www.codeinn.net/misctech/38189.html