1 |
package soo.base; |
---|
2 |
|
---|
3 |
import android.app.Activity; |
---|
4 |
import android.os.Bundle; |
---|
5 |
import android.view.ViewGroup; |
---|
6 |
import android.widget.Button; |
---|
7 |
import android.widget.LinearLayout; |
---|
8 |
import android.widget.TextView; |
---|
9 |
|
---|
10 |
public class Hello2T extends Activity { |
---|
11 |
/** Called when the activity is first created. */ |
---|
12 |
@Override |
---|
13 |
public void onCreate(Bundle savedInstanceState) { |
---|
14 |
super.onCreate(savedInstanceState); |
---|
15 |
//setContentView(R.layout.main); |
---|
16 |
|
---|
17 |
LinearLayout ll = new LinearLayout(this); |
---|
18 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
---|
19 |
ViewGroup.LayoutParams.FILL_PARENT, |
---|
20 |
ViewGroup.LayoutParams.FILL_PARENT, |
---|
21 |
0.0f |
---|
22 |
); |
---|
23 |
ll.setLayoutParams(params); |
---|
24 |
ll.setOrientation(LinearLayout.VERTICAL); |
---|
25 |
|
---|
26 |
//TextView |
---|
27 |
TextView tv = new TextView(this); |
---|
28 |
tv.setText(R.string.hello); |
---|
29 |
|
---|
30 |
LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams( |
---|
31 |
ViewGroup.LayoutParams.FILL_PARENT, |
---|
32 |
ViewGroup.LayoutParams.WRAP_CONTENT, |
---|
33 |
0.0f |
---|
34 |
); |
---|
35 |
|
---|
36 |
tv.setLayoutParams(tvParams); |
---|
37 |
ll.addView(tv); |
---|
38 |
|
---|
39 |
//Button 1 |
---|
40 |
Button btn = new Button(this); |
---|
41 |
btn.setText("踰��1"); |
---|
42 |
|
---|
43 |
LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams( |
---|
44 |
ViewGroup.LayoutParams.FILL_PARENT, |
---|
45 |
ViewGroup.LayoutParams.FILL_PARENT, |
---|
46 |
0.0f |
---|
47 |
); |
---|
48 |
btn.setLayoutParams(btnParams); |
---|
49 |
|
---|
50 |
ll.addView(btn); |
---|
51 |
|
---|
52 |
//Button 2 |
---|
53 |
Button btn2 = new Button(this); |
---|
54 |
btn2.setText("踰��2"); |
---|
55 |
ll.addView(btn2); |
---|
56 |
|
---|
57 |
setContentView(ll); |
---|
58 |
} |
---|
59 |
} |
---|