• 安卓作业


    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>

  • 相关阅读:
    Eclipse中使用Working Set来管理项目
    Hibernate基于注解方式配置来实现实体和数据库之间存在某种映射关系
    身份证工具类,可以解析出身份证号是否通过校验、性别、年龄和出生所在地
    使用Spring整合Hibernate,并实现对数据表的增、删、改、查的功能
    Hibernate案例-------基于xml配置,使用Hibernate实现对员工表的增、删、改、查功能
    Hibernate学习笔记整理系列-------一、Hibernate简介
    基于注解配置的Spring MVC 简单的HelloWorld实例应用
    基于XML配置的Spring MVC 简单的HelloWorld实例应用
    详细的图文教程来实现 eclipse环境下如何配置tomcat,并且把项目部署到Tomcat服务器上
    webstorm 注册码
  • 原文地址:https://www.cnblogs.com/gwz-1314/p/14007902.html
Copyright © 2020-2023  润新知