80,359
社区成员
发帖
与我相关
我的任务
分享
<?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/tv1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/intro" />
<EditText android:id="@+id/height" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numeric="integer" />
<RadioGroup android:id="@+id/sex" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<RadioButton android:id="@+id/male" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/male" />
<RadioButton android:id="@+id/female"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/female" />
</RadioGroup>
<Button android:id="@+id/submit" android:text="@string/submit"
android:layout_width="50pt" android:layout_height="wrap_content" />
</LinearLayout>
<?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">
<TextView android:id="@+id/result" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button android:id="@+id/back" android:layout_width="50pt"
android:layout_height="wrap_content" android:text="@string/back" />
</LinearLayout>
IntentDemo.java
package com.android.jiashie;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
import android.content.Intent;
public class IntentDemo extends Activity {
private EditText height;
private RadioButton sex;
private Button btn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv1 = (TextView)findViewById(R.id.tv1);
tv1.setText(R.string.intro);
height=(EditText)findViewById(R.id.height);
sex = (RadioButton)findViewById(R.id.sex);
btn = (Button)findViewById(R.id.submit);
btn.setText(R.string.submit);
btn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
//TODO:
}
});
}
}
package com.android.jiashie;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
public class ResultActivity extends Activity
{
private Button btn;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
btn = (Button)findViewById(R.id.back);
btn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
//TODO:
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, IntentDemo!</string>
<string name="app_name">IntentDemo</string>
<string name="result">计算结果</string>
<string name="intro">输入你的身高(cm)</string>
<string name="male">男</string>
<string name="female">女</string>
<string name="submit">提交</string>
<string name="back">返回</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.jiashie"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".IntentDemo"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ResultActivity"
android:label="@string/result">
</activity>
</application>
</manifest>