zoukankan      html  css  js  c++  java
  • 和小伙伴的结伴编程

    和徐鹏小伙伴的结对编程

    由于我能力比较弱我就写了一个小软件简单的登陆

    :)

    package com.example.chen;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            final EditText mUserName = (EditText) this.findViewById(R.id.editText1);
            final EditText mPassword = (EditText) this.findViewById(R.id.editText2);
            Button mSubmit =  (Button)this.findViewById(R.id.button1);
            final TextView mResult = (TextView)this.findViewById(R.id.textView1);
            mSubmit.setOnClickListener( new OnClickListener() {
                
                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                       String userName = mUserName.getText().toString();
                       String password = mPassword.getText().toString();
                       if("hudaochen".equals(userName) && "123".equals(password)){
                           mResult.setText("恭喜您,登录成功!");
                       }else{
                           mResult.setText("登录失败,用户名或密码不正确!");
                       }
                       
           }
    
       } );
                
    
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }
    }
    <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout 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.chen.MainActivity" 
        android:orientation="vertical">
    
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="输入用户名"
            android:ems="10"
            android:text="" />
    
        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="输入密码"
            android:text=""
            android:ems="10"
            android:inputType="textPassword" />
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登陆" />
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="登陆结果"/>
    
    </LinearLayout>

    我写一半他写一半遇到不会的他指导我一下

  • 相关阅读:
    如何在xml中存储图片
    软件开发平台化催生软件产业链新层级(1)
    在sql server 中如何移动tempdb到新的位置
    Base64在XML中存储图片的解决方案
    东软金算盘VP*台:拆分标准与个性
    浪潮“楼上”开发平台简介
    python模块整理3random模块
    python模块整理1os模块
    python学习笔记18重点和忘记知识点总结
    python模块整理8glob(类似grep)和fnmatch(匹配文件名)
  • 原文地址:https://www.cnblogs.com/hudaochen/p/6637669.html
Copyright © 2011-2022 走看看