zoukankan      html  css  js  c++  java
  • 安卓作业

    package com.example.app;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.text.style.ClickableSpan;
    import android.util.Log;
    import android.view.Menu;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.RadioGroup;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
        private RadioGroup radioGroup;
        private TextView textView;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            radioGroup = (RadioGroup) findViewById(R.id.rdg);
            textView=(TextView) findViewById(R.id.tv4);
            radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                
                
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    if(checkedId==R.id.man){
                        textView.setText("您的性别为:男");
                    }else{
                        textView.setText("您的性别为:女");
                    }
                    // TODO Auto-generated method stub
                    
                }
            });
            Log.i("MainActivity", "调用onCreate()");
        }
        protected void onStart(){
            super.onStart();
            Log.i("MainActivity","调用onStart()");
        }
    @Override
    
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        Log.i("MainActivity", "调用onResume()");
    }
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        Log.i("MainActivity", "调用onPause()");
    }
    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        Log.i("MainActivity", "调用onStop()");
    }
    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        Log.i("MainActivity", "调用onDestory()");
    }
    @Override
    protected void onRestart() {
        // TODO Auto-generated method stub
        super.onRestart();
        Log.i("MainActivity", "调用onRestart()");
    }
    
    public void click(View v){
        switch (v.getId()) {
        case R.id.btn1:
            Intent it1=new Intent(this,SecondActivity.class);
            String name=((EditText)findViewById(R.id.et1)).getText().toString();
            String id=((EditText)findViewById(R.id.et1)).getText().toString();
            it1.putExtra("name", name);
            it1.putExtra("age",id);            
            startActivity(it1);
            break;
        
        default:
            break;
        }
    }
    }
    
    
    
    package com.example.app;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.widget.Toast;
    
    
    public class SecondActivity extends Activity{
        
    protected void onCreate(Bundle savedlnstanceState){
        super.onCreate(savedlnstanceState);
        setContentView(R.layout.second);
        setContentView(R.layout.activity_main);
        
    }
    @Override
        protected void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            Log.i("2222222222222", "界面2调用了Onstart");
            Intent intent=getIntent();
            String name=intent.getStringExtra("name");
            int id=intent.getIntExtra("id", 0);
            Toast.makeText(this, name+"你好,密码是:"+id, id).show();
    }
            
    @Override
    protected void onResume(){
        // TODO Auto-generated method stub
        super.onResume();
        Log.i("2222222222222", "界面2调用了Onresume");
    }
    
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        Log.i("2222222222222", "界面2调用了Onpause");
    }
    
    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        Log.i("2222222222222", "界面2调用了Onstop");
    }
    
    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        Log.i("2222222222222", "界面2调用了OnDestroy");
    }
    
    
    
    }
    
    
    <?xml version="1.0" encoding="utf-8"?><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=".MainActivity" 
        android:orientation="vertical">
       
      <TextView
            android:id="@+id/tv1"
            android:layout_width="90dp"
            android:layout_height="wrap_content" 
            android:text="请输入用户名:"      
            android:onClick="click"/>
    
         <TextView
             android:id="@+id/tv2"
             android:layout_width="90dp"
             android:layout_height="wrap_content"
             android:layout_alignLeft="@+id/tv1"
             android:layout_below="@+id/tv1"
             android:layout_marginTop="18dp"
             android:onClick="click"
             android:text="请输入密码:" />
    
         <EditText
             android:id="@+id/et1"
             android:layout_width="90dp"
             android:layout_height="wrap_content"
             android:layout_above="@+id/et2"
             android:layout_alignRight="@+id/btn1"
             android:maxLines="2"
             android:textSize="20sp"
             android:textStyle="italic"
             android:ems="10" />
    
         <EditText
             android:id="@+id/et2"
             android:layout_width="90dp"
             android:layout_height="wrap_content"
             android:layout_alignLeft="@+id/et1"
             android:layout_alignRight="@+id/et1"
             android:layout_alignTop="@+id/tv2"
             android:textSize="20sp"
             android:textStyle="italic"
             android:ems="10" >
         
      
             <requestFocus />
             </EditText>
            <RadioGroup
                android:id="@+id/rdg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                >
                </RadioGroup>
            
            
            <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:textSize="15sp"/>
    
            <Button
                android:id="@+id/btn1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="36dp"
                android:onClick="click"
                android:text="注册按钮"
                android:textColor="#000000" />
    
            <RadioButton
                android:id="@+id/man"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/btn1"
                android:layout_below="@+id/et2"
                android:layout_marginTop="22dp"
                android:text="男"
                android:textSize="15sp" />
    
            <RadioButton
                android:id="@+id/women"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/man"
                android:layout_alignBottom="@+id/man"
                android:layout_toRightOf="@+id/et2"
                android:text="女"
                android:textSize="15sp" />
    
            <TextView
                android:id="@+id/tv3"
                android:layout_width="90dp"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/man"
                android:layout_alignBottom="@+id/man"
                android:layout_alignLeft="@+id/tv2"
                android:onClick="click"
                android:text="性别" />
        
    </RelativeLayout>
       
       
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        
    <Button android:id="@id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注册信息"/>"
        
    </LinearLayout>

  • 相关阅读:
    经典51懒人5步速成法
    C语言数组元素的查询
    C语言二维数组
    C语言数组的概念
    C语言基础之水仙花数
    说说M451例程讲解之定时器
    位运算符、按位与、按位或、按位非、左移、右移、原码、反码、补码
    语音中的关于语音识别的一些知识
    caffe的db_lmdb.hpp文件
    lmdb存储的一些库相关函数
  • 原文地址:https://www.cnblogs.com/gwz-1314/p/14007902.html
Copyright © 2011-2022 走看看