package csie.stut.edu.tw;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
public class Test1Activity extends Activity {
/** Called when the activity is first created. */
Button button1;
OnClickListener listener1=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listener1 = new OnClickListener(){
public void onClick(View v){
Intent intent1 = new Intent(Test1Activity.this, ActivityRelativeLayout.class);
startActivity(intent1);
}
};
setContentView(R.layout.main);
button1=(Button)findViewById(R.id.button1);
button1.setOnClickListener(listener1);
}
}
====================================================================
//ActivityRelativeLayout.java
package csie.stut.edu.tw;
import android.app.Activity;
import android.os.Bundle;
public class ActivityRelativeLayout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.relative_layout);
}
}
====================================================================
//main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:text="下一頁(Relative Layout)" >
</Button>
</LinearLayout>
====================================================================
//relative_layout
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="請輸入用戶名" >
</TextView>
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="60dp"
android:layout_marginTop="33dp"
android:layout_toRightOf="@+id/textView1" >
<requestFocus >
</requestFocus>
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginLeft="29dp"
android:layout_marginTop="20dp"
android:text="Button" >
</Button>
</RelativeLayout>
====================================================================
//Test1Activity Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="csie.stut.edu.tw"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".Test1Activity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="RelativeLayout Demo"
android:name=".ActivityRelativeLayout" >
</activity>
</application>
</manifest>
關於 小巴 | ||
出現在網路上的小小部落客,白天是隱身在某某科大的學生,一到晚上就會現身在傳說中的秘密工作室。對於3C和網路有高度的熱情,偶爾研究APP、寫寫程式,是個最近很忙碌的學生。 |
||
沒有留言:
張貼留言
請提供您寶貴的意見