• andorid 练习微信登陆


    AndroidManifest.xml

    layout1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/denglu"
            android:onClick="wx1"
    
            />
    </LinearLayout>

    Layout1.java

    package com.hanqi.application3;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout1 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout1);
    
        }
        public void wx1(View view)
        {
            Intent intent = new Intent(this,Layout2.class);
            startActivity(intent);
        }
    }

    layout2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="0dp">
    
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/tiaozhuan"
         android:scaleType="fitXY"
    android:padding="0dp" /> 

    </LinearLayout>

    layout2.java

    package com.hanqi.application3;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout2 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout2);
    
        final Intent it = new Intent(this,Layout3.class); //你要转向的Activity
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
    
                startActivity(it); //执行
            }
        };
    
        timer.schedule(task, 1000 * 5); //5秒后
    
        }
    }

    layout3.xml

    <?xml version="1.0" encoding="utf-8"?>
    <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:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/anniu001"
            android:text="登陆"
            android:onClick="wx2"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/anniu001"
            android:text="注册"
            android:onClick="wx3"
    
        />
    
    </LinearLayout>

    Layout3.java

    package com.hanqi.application3;
    
    import android.app.AlertDialog;
    import android.app.ProgressDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout3 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout3);
        }
        public void wx2(View v)
        {
    
            //获取加载器
            LayoutInflater layoutInflater = getLayoutInflater();
            //加载layout文件
            View vi_1 = layoutInflater.inflate(R.layout.layout5,null);
            //添加按钮
            new AlertDialog.Builder(this)
                    .setView(vi_1)
                    .setNegativeButton("取消", null)
                    .setPositiveButton("登陆", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
    
                            AlertDialog al = (AlertDialog) dialog;
    
                            EditText pwd = (EditText) al.findViewById(R.id.et_pw);
    
                            String str = pwd.getText().toString();
    
                            if (str.equals("123456")) {
                                Intent intent = new Intent(Layout3.this, Layout4.class);
                                startActivity(intent);
                            } else {
                                Toast.makeText(Layout3.this, "密码错误!", Toast.LENGTH_SHORT).show();
                            }
    
                        }
                    })
                    .show();
        }
        public void wx3(View v)
        {
            final ProgressDialog pd = new ProgressDialog(this);
            pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    
            pd.setMessage("请稍后");
            pd.show();
    
            //创建thread实例  重写run方法  启动多线程
            new Thread()
            {
                @Override
                public void run() {
                    super.run();
                    for (int i = 0;i<=pd.getMax();i++)
                    {
                        try {
                            Thread.sleep(100);
                        }catch (Exception e)
                        {}
                        pd.setProgress(i);
                    }
                    pd.dismiss();
                }
            }.start();
        }
    
    }

    layout4.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/da4"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/da1"/>
    
    </LinearLayout>

    Layout4.java

    package com.hanqi.application3;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout4 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout4);
        }
    }

    layout5.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/denglu"
            android:layout_gravity="center_horizontal"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="123456"
            android:layout_gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="密码"
            android:inputType="textPassword"
            android:id="@+id/et_pw"/>
    </LinearLayout>

    ---恢复内容结束---

    AndroidManifest.xml

    layout1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/denglu"
            android:onClick="wx1"
    
            />
    </LinearLayout>

    Layout1.java

    package com.hanqi.application3;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout1 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout1);
    
        }
        public void wx1(View view)
        {
            Intent intent = new Intent(this,Layout2.class);
            startActivity(intent);
        }
    }

    layout2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="0dp">
    
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/tiaozhuan"
    
            android:padding="0dp"
            />
    
    </LinearLayout>

    layout2.java

    package com.hanqi.application3;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout2 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout2);
    
        final Intent it = new Intent(this,Layout3.class); //你要转向的Activity
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
    
                startActivity(it); //执行
            }
        };
    
        timer.schedule(task, 1000 * 5); //5秒后
    
        }
    }

    layout3.xml

    <?xml version="1.0" encoding="utf-8"?>
    <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:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/anniu001"
            android:text="登陆"
            android:onClick="wx2"
            />
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/anniu001"
            android:text="注册"
            android:onClick="wx3"
    
        />
    
    </LinearLayout>

    Layout3.java

    package com.hanqi.application3;
    
    import android.app.AlertDialog;
    import android.app.ProgressDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout3 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout3);
        }
        public void wx2(View v)
        {
    
            //获取加载器
            LayoutInflater layoutInflater = getLayoutInflater();
            //加载layout文件
            View vi_1 = layoutInflater.inflate(R.layout.layout5,null);
            //添加按钮
            new AlertDialog.Builder(this)
                    .setView(vi_1)
                    .setNegativeButton("取消", null)
                    .setPositiveButton("登陆", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
    
                            AlertDialog al = (AlertDialog) dialog;
    
                            EditText pwd = (EditText) al.findViewById(R.id.et_pw);
    
                            String str = pwd.getText().toString();
    
                            if (str.equals("123456")) {
                                Intent intent = new Intent(Layout3.this, Layout4.class);
                                startActivity(intent);
                            } else {
                                Toast.makeText(Layout3.this, "密码错误!", Toast.LENGTH_SHORT).show();
                            }
    
                        }
                    })
                    .show();
        }
        public void wx3(View v)
        {
            final ProgressDialog pd = new ProgressDialog(this);
            pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    
            pd.setMessage("请稍后");
            pd.show();
    
            //创建thread实例  重写run方法  启动多线程
            new Thread()
            {
                @Override
                public void run() {
                    super.run();
                    for (int i = 0;i<=pd.getMax();i++)
                    {
                        try {
                            Thread.sleep(100);
                        }catch (Exception e)
                        {}
                        pd.setProgress(i);
                    }
                    pd.dismiss();
                }
            }.start();
        }
    
    }

    layout4.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/da4"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/da1"/>
    
    </LinearLayout>

    Layout4.java

    package com.hanqi.application3;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    /**
     * Created by Administrator on 2016/4/4.
     */
    public class Layout4 extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.layout4);
        }
    }

    layout5.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/denglu"
            android:layout_gravity="center_horizontal"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="123456"
            android:layout_gravity="center_horizontal"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="密码"
            android:inputType="textPassword"
            android:id="@+id/et_pw"/>
    </LinearLayout>
  • 相关阅读:
    winsock编程WSAAsyncSelect模型
    winsock编程select模型
    socket编程,简单多线程服务端测试程序
    模板singleton模式的C++实现
    windows socket函数详解
    ACE_Message_Block消息数据类
    ACE Socket Wrapper Facade
    ACE_Event_Handler:事件响应入口
    ACE_Time_Value
    华为ICDcomm接口js测试
  • 原文地址:https://www.cnblogs.com/cuikang/p/5353352.html
Copyright © 2020-2023  润新知