标签:eth case auto star cas XML vat etc generated
package com.example.sevenzuoy; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity implements View.OnClickListener{ private EditText mPhone; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button mBu = (Button) findViewById(R.id.bu); mBu.setOnClickListener(this); mPhone = (EditText) findViewById(R.id.phone); } @Override public void onClick(View v) { // TODO Auto-generated method stub int Phone = Integer.parseInt(mPhone.getText().toString()); Intent intent = new Intent(MainActivity.this, MyActivity.class); intent.putExtra("phone", Phone); startActivityForResult(intent, 1); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (resultCode) { case 1: int money = data.getIntExtra("money", 0); Toast.makeText(this, "您充值的钱数为"+money+"", 0).show(); break; default: Toast.makeText(this, "充值失败", 0).show(); break; } } }
package com.example.sevenzuoy; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class MyActivity extends Activity { private EditText Money; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); TextView Phone = (TextView) findViewById(R.id.phone); Intent intent = getIntent(); int phone = intent.getIntExtra("phone", 0); Phone.setText(phone+""); Money = (EditText) findViewById(R.id.money); } public void yes(View v) { int money = Integer.parseInt(Money.getText().toString()); Intent intent = new Intent(); intent.putExtra("money", money); setResult(1, intent); finish(); } public void no(View v) { Intent intent = new Intent(); setResult(2, intent); finish(); } }
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.sevenzuoy.MainActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请输入您的手机号" /> <EditText android:id="@+id/phone" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <Button android:id="@+id/bu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="充值" android:layout_centerInParent="true" /> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.sevenzuoy.MyActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="您的号码是:" /> <TextView android:id="@+id/phone" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerVertical="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请输入充值金额"/> <EditText android:id="@+id/money" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="yes" android:text="充值" android:layout_alignParentBottom="true"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="no" android:text="取消" android:layout_alignParentBottom="true" android:layout_alignParentRight="true"/> </RelativeLayout>
标签:eth case auto star cas XML vat etc generated
原文地址:https://www.cnblogs.com/lyccc/p/12915336.html