zoukankan      html  css  js  c++  java
  • 第三次作业

    <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:background="#e7e7e7"
        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.qq.MainActivity" >
        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
                <LinearLayout 
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="vertical">
                    <LinearLayout 
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
                     android:layout_weight="1"
                     android:background="#e7e7e7">
    
                        <ImageView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:src="@drawable/abcd" 
                            android:layout_marginBottom="50dp"/>
     
                     </LinearLayout>  
                          <LinearLayout 
                           android:layout_width="match_parent"
                           android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="vertical">
                           <LinearLayout 
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="#ffffff"
                            android:orientation="horizontal">
                        <TextView 
                         
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:text="账号"
                            android:textColor="#000000"
                            android:gravity="center_vertical"
                            android:layout_marginLeft="8dp"
                            android:layout_weight="1"/>
    
                        <EditText
                             android:id="@+id/admin"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:hint="QQ账号"
                            android:textColor="#000000"
                            android:layout_weight="7" />
                              <TextView 
                                            android:id="@+id/admin1" 
                                            android:layout_width="0dp"
                                            android:layout_height="0dp"
                                            android:text="123456"
                                                               />
                         </LinearLayout> 
                         <LinearLayout 
                           android:layout_width="match_parent"
                           android:layout_height="match_parent"
                           android:layout_weight="1"
                           android:background="#ffffff"
                           android:layout_marginTop="5dp"
                           android:orientation="horizontal">
    
                             <TextView
                                 android:layout_width="0dp"
                                 android:layout_height="match_parent"
                                 android:layout_marginLeft="8dp"
                                 android:layout_weight="1"
                                 android:text="密码"
                                 android:gravity="center_vertical"
                                 android:textColor="#000000" />
    
                        <EditText
                            android:id="@+id/password"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:gravity="center_vertical"
                            android:hint="QQ密码"
                            android:inputType="textPassword"
                            android:textColor="#000000"
                            android:layout_weight="7"  />
                        
                         </LinearLayout> 
                         </LinearLayout> 
                         </LinearLayout>
                <LinearLayout 
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="vertical">
                           <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:orientation="vertical" 
                android:layout_weight="1">
    
                               <Button
                                   android:id="@+id/login"
                                   android:layout_width="match_parent"
                                   android:layout_height="wrap_content"
                                   android:layout_marginTop="15dp"
                                   android:background="#398ec6"
                                   android:onClick="click"
                                   android:text="登录" />
             <TextView 
            android:id="@+id/textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="40dp"
            android:textSize="15dp" />                          
        </LinearLayout>
      </LinearLayout>
      </LinearLayout>
    </RelativeLayout>


    package com.example.qq;
    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;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
         private EditText madmin;
         private EditText mpassword;
         private Button mlogin;
         private TextView mtextview;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            madmin = (EditText) findViewById(R.id.admin);
            mpassword = (EditText) findViewById(R.id.password);
            mlogin = (Button) findViewById(R.id.login);
            mtextview = (TextView) findViewById(R.id.textview);
            mlogin.setOnClickListener(new OnClickListener() {
                
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    String admin = madmin.getText().toString();
                    String password = mpassword.getText().toString();
                    if("123456".equals(admin)&&"abc123".equals(password)){
                        Toast.makeText(MainActivity.this,"登录成功",0).show();
                    }else{
                        mtextview.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);
        }
    }
    
    

  • 相关阅读:
    Android 8.0 adb shell dumpsys activity activities | findstr mFocusedActivity 获取当前的 activity 显示空的
    spring-in-action_day01
    spring-in-action_day02
    spring-in-action-day04-配置属性 @ConfigurationProperties
    springmvc接收参数
    spring中Utils工具类注入问题
    Eclipse Push出现rejected
    Eclpis-cannot open git-receive-pack
    IO
    LinkedHashmap简要说明
  • 原文地址:https://www.cnblogs.com/lj1221/p/11543122.html
Copyright © 2011-2022 走看看