編輯:高級開發
< ?XML version="1.0" encoding="utf-8"?>
< LinearLayout XMLns:android="http://schemas.android.com/apk/res/android"
android:orIEntation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
< TextView android:id="@+id/textVIEw1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
< Button android:id="@+id/btnTV" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/btn" />
< /LinearLayout>
test.XML文件內容如下:
< ?XML version="1.0" encoding="utf-8"?>
< LinearLayout XMLns:android="http://schemas.android.com/apk/res/android"
android:orIEntation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
< TextVIEw android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/tvSecond" />
< /LinearLayout>
對應Main.Java內容如下:
public class Main extends Activity implements OnClickListener {
private Button btnTV;
private TextView textVIEw1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentVIEw(R.layout.main);
LinearLayout mainLinearLayout = (LinearLayout) this.getLayoutInflater()
.inflate(R.layout.main, null);
setContentVIEw(mainLinearLayout);
btnTV = (Button) this.findVIEwById(R.id.btnTV);
textView1 = (TextView) this.findViewById(R.id.textVIEw1);
btnTV.setOnClickListener(this);
LinearLayout testLinearLayout = (LinearLayout) this.getLayoutInflater()
.inflate(R.layout.test, mainLinearLayout);
接上頁
EditText editText = new EditText(this);
editText.setSingleLine(false);
editText.setGravity(Gravity.LEFT);
mainLinearLayout.addVIEw(editText, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
@Override
public void onClick(VIEw v) {
int value = textVIEw1.getGravity() & 0x07;
if (value == Gravity.LEFT) {
textVIEw1.setGravity(Gravity.CENTER_HORIZONTAL);
} else {
if (value == Gravity.CENTER_HORIZONTAL) {
textVIEw1.setGravity(Gravity.RIGHT);
} else {
textVIEw1.setGravity(Gravity.LEFT);
}
}
}
}
tp://images.cnblogs.com/cnblogs_com/phinecos/20080415/2009082805.jpg border=0 alt= w
一、安裝 JDK 下載JDK最新版本,下載地址如下: http://www.Oracle.com/technetwork/java/Javase/downloads
我們曾經給大家一個《MeeGo移動終端設備開發UI設計基礎教程》,同時很多朋友都在尋找android UI開發的教程,我們從Android的官方開發者博客找了一份幻燈片
/developer.android.com/sdk/installing.Html(洋文,被牆) 下載後解壓。 假設解壓後是/home/chen/下載/andro