zoukankan      html  css  js  c++  java
  • 第七次作业(2)

    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>

  • 相关阅读:
    sql server 查询出的结果集,拼接某一列赋值给一个变量
    sql server显示某一列中有重复值的行
    webservice 尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下运行,将出现此问题
    Merge Into 用法
    修改TFS与本地源代码映射路径
    Thinkphp5.0第五篇
    aircrack-ng wifi密码破解
    Thinkphp5.0第四篇
    Thinkphp5.0第三篇
    Thinkphp5.0第二篇
  • 原文地址:https://www.cnblogs.com/lj1221/p/11719204.html
Copyright © 2011-2022 走看看