android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/factorOne"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:id="@+id/symbol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
android:id="@+id/factorTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
android:id="@+id/calculate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
ResultActivity中的代码
1.接受从Activity03当中所传递的值
2.计算两个值的积
3.将计算的结果显示在Activity上
public class ResultActivity extends Activity{
private TextView resultView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
resultView = (TextView)findViewById(R.id.result);
//得到Intent对象当中的值
Intent intent = getIntent();
//通过键值对取值
String factorOneStr = intent.getStringExtra("one");
String factorTwoStr = intent.getStringExtra("two");
//因为是String,不能相乘 ,所以先换算成整型
int factorOneInt = Integer.parseInt(factorOneStr);
int factorTwoInt = Integer.parseInt(factorTwoStr);
//计算两个值的积
int result = factorOneInt * factorTwoInt;
resultView.setText(result + "");
}
}
Layout中相应的result.xml中的配置
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
Values中String.xml中的配置:配置ID号,方便可以通过ID来引用,方便以后代码的改写
Hello World, Activity03!
activity03
result
乘以
计算
退出
关于
Manifest.xml的配置:主要是配置哪个Activity先启动等一些信息
package="mars.activity03"
android:versionCode="1"
android:versionName="1.0">
android:label="@string/app_name">