运行效果图:
MainActivity.java代码如下:
package com.example.mfc2;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import java.text.DecimalFormat;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity
{
private Button button1;
private EditText edittext;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.bu1);
edittext = (EditText) findViewById(R.id.editText1);
button1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String a = edittext.getText().toString();
int b = Integer.parseInt(a);
double x = (b - 80) * 0.7;
double y = (b - 70) * 0.6;
DecimalFormat df = new DecimalFormat( "0.0 ");
Intent intent = new Intent(MainActivity.this, TwoActivity.class);
RadioButton rb1 = (RadioButton) findViewById(R.id.radiobutton1);
RadioButton rb2 = (RadioButton) findViewById(R.id.radiobutton2);
boolean is1 = rb1.isChecked();
boolean is2 = rb2.isChecked();
if (is1)
{
intent.putExtra("xingbie",