Android课程---qq登陆页面(练习)

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hanqi.test3">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Activity1">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Activity3">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".ActivityLast">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Activity1.java

package com.hanqi.test3;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import java.util.Timer;
import java.util.TimerTask;

public class Activity1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_1);
//        Intent intent = new Intent(this,Activity3.class);
        final Intent localIntent = new Intent(this, Activity3.class);
        Timer timer = new Timer();
        TimerTask tast = new TimerTask() {
            @Override
            public void run() {
                startActivity(localIntent);
            }
        };
        timer.schedule(tast,4000);

    }
}

Activity3.java

package com.hanqi.test3;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Activity3 extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_3);

    }
   public void onclick1 (View v)
   {
       new AlertDialog.Builder(this)

           .setView(R.layout.loginlayout)
           .setNeutralButton("取消", null)
           .setPositiveButton("登陆", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                   AlertDialog al = (AlertDialog) dialog;
                   EditText ed_pw = (EditText) al.findViewById(R.id.ed_pw);
                   String str = ed_pw.getText().toString();
                   if (str.equals("123456")) {
                       Intent intent = new Intent(Activity3.this, ActivityLast.class);
                       startActivity(intent);
                   } else {
                       Toast.makeText(Activity3.this, "密码错误,请重新输入", Toast.LENGTH_SHORT).show();
                   }

               }
           })
           .setCancelable(false)
           .show();
   }
    public void onclick2(View v)
    {
        new AlertDialog.Builder(this)
            .setView(R.layout.loginlayout2)
                .setPositiveButton("提交注册", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        AlertDialog al = (AlertDialog) dialog;
                        TextView nc_qq = (TextView) al.findViewById(R.id.nc_qq);
                        Toast.makeText(Activity3.this, "注册成功!", Toast.LENGTH_SHORT).show();
                    }
                })
                .show();

    }
    public void onclick3(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();
    }

}

ActivityLast.java

package com.hanqi.test3;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class ActivityLast extends AppCompatActivity
{

    List<Haoyou> lf;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_last);

        ListView yemian =(ListView)findViewById(R.id.yemian);
        //准备数据源
        lf = new ArrayList<Haoyou>();
        lf.add(new Haoyou(R.drawable.qq,"会飞的企鹅","[在线]明天上课!"));
        lf.add(new Haoyou(R.drawable.qq,"明日依旧","[在线]明天上课!2"));
        lf.add(new Haoyou(R.drawable.qq, "会飞的企鹅3", "[在线]明天上课!3"));
        lf.add(new Haoyou(R.drawable.qq, "会飞的企鹅4", "[在线]明天上课!4"));
        yemian.setAdapter(new MyBaseAdapter());

    }
    class MyBaseAdapter extends BaseAdapter
    {

        @Override
        public int getCount()
        {

            return lf.size();
        }

        @Override
        public Object getItem(int position)
        {
            return lf.get(position);
        }

        @Override
        public long getItemId(int position)
        {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {

            if (convertView == null)
            {
                Log.e("TAG", "position = " + position);

                LayoutInflater layoutInflater = getLayoutInflater();
                convertView = layoutInflater.inflate(R.layout.loginlayout3, null);
            }

                Haoyou haoyou = lf.get(position);

                ImageView qq = (ImageView) convertView.findViewById(R.id.tx_qq);
                TextView tv1 = (TextView) convertView.findViewById(R.id.tv1);
                TextView tv2 = (TextView) convertView.findViewById(R.id.tv2);

                qq.setImageResource((int) haoyou.getImage());
                tv1.setText(haoyou.getName());
                tv2.setText(haoyou.getContent());

                return convertView;

        }
    }
}

Haoyou.java

package com.hanqi.test3;

/**
 * Created by Administrator on 2016/4/9.
 */
public class Haoyou {

    private int image;
    private String name;
    private String content;

    public Haoyou(int image, String name, String content) {
        this.image = image;
        this.name = name;
        this.content = content;
    }

    public void setName(String name) {
        this.name = name;

    }

    public void setImage(int image) {
        this.image = image;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getImage() {

        return image;
    }

    public String getName() {
        return name;
    }

    public String getContent() {
        return content;
    }
    @Override
    public String toString() {
        return "Haoyou{" +
                "image=" + image +
                ", name=‘" + name + ‘\‘‘ +
                ", content=‘" + content + ‘\‘‘ +
                ‘}‘;
    }
}

MainActivity.java

package com.hanqi.test3;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void onclick(View v)
         {
             Intent intent = new Intent(this,Activity1.class);
             startActivity(intent);

         }

    }

activity_main.xml

<?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"
    tools:context="com.hanqi.test3.MainActivity"
    android:padding="20dp">

    <ImageButton
        android:layout_width="68dp"
        android:layout_height="68dp"
        android:src="@drawable/mobileqq"
        android:onClick="onclick"/>
</RelativeLayout>

activity_3.xml

<?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"
    tools:context="com.hanqi.test3.Activity3"
    android:orientation="vertical"
    android:gravity="center">
    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/qq"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登陆"
        android:id="@+id/dl_qq"
        android:onClick="onclick1"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注册"
        android:id="@+id/zc_qq"
        android:onClick="onclick2"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="升级最新版"
        android:id="@+id/sj_qq"
        android:onClick="onclick3"/>

</LinearLayout>

activity_1.xml

<?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"
    tools:context="com.hanqi.test3.Activity1">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/beijing"/>

</RelativeLayout>

activity_last.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="#0ff"
    android:dividerHeight="3dp"
    android:id="@+id/yemian">

</ListView>

loginlayout.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="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/title"
        android:scaleType="fitXY"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="用户名"
        android:id="@+id/ed_username"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="密码"
        android:inputType="textPassword"
        android:id="@+id/ed_pw"/>

</LinearLayout>

loginlayout2.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">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="昵称"
        android:padding="10dp"
        android:id="@+id/nc_qq"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="昵称不可以为空"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密码"
        android:padding="10dp"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="长度为6-16个字符"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="生日"
            android:padding="10dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性别"
            android:padding="10dp"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="男"
            />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="女"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="地区"
            android:padding="10dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="手机号"
            android:padding="10dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="必须是数字"/>
    </LinearLayout>

</LinearLayout>

loginlayout.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="50dp"
        android:layout_height="50dp"
        android:src="@drawable/qq"
        android:id="@+id/tx_qq"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="20dp">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="会飞的企鹅"
            android:id="@+id/tv1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="[在线]明天上课!"
            android:id="@+id/tv2"/>

    </LinearLayout>

</LinearLayout>

效果图如下:

时间: 2024-08-14 22:08:58

Android课程---qq登陆页面(练习)的相关文章

.Net程序员玩转Android开发---(3)登陆页面布局

这一节我们来看看登陆页面怎样布局,对于刚接触到Android开发的童鞋来说,Android的布局感觉比较棘手,需要结合各种属性进行设置,接下来我们由点入面来 了解安卓中页面怎样布局,登陆页面很简单,两个文本框和一个按钮,页面效果如下:

QQ互联OAuth2.0 .NET SDK 发布以及网站QQ登陆示例代码

OAuth: OAuth(开放授权)是一个开放标准,允许用户授权第三方网站访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方网站或分享他们数据的所有内容. QQ登录OAuth2.0:对于用户相关的OpenAPI(例如获取用户信息,动态同步,照片,日志,分享等),为了保护用户数据的安全和隐私,第三方网站访问用户数据前都需要显式的向用户征求授权. QQ登录OAuth2.0采用OAuth2.0标准协议来进行用户身份验证和获取用户授权,相对于之前的OAuth1.0协议,其认证流程

Android之十一实现登陆页面分析

Android之十一实现登陆页面分析 二.登录界面的布局分析 1.login.xml Step1:首先建立drawable 文件夹,创建logintopbg_roundcorner.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid a

Android笔记-4-实现登陆页面并跳转和简单的注册页面

实现登陆页面并跳转和简单的注册页面 首先我们来看看布局的xml代码 login.xml <span style="font-family:Arial;font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu

Android简单登陆页面

布局: 线性布局+相对布局 日志打印: 利用LogCat和System.out.println打印观察. Onclick事件是采用过的第四种: 在配置文件中给Button添加点击时间 涉及知识: 通过上线文context获得文件的路径和缓存路径,保存文件 布局代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.an

Android网络项目课程笔记-----欢迎页面新手引导

1. 欢迎页面 1) 分析 2) 规则 (1) 在2.3没有titlebar,在4.x没有Actionbar     OK (2) 第一次进入程序才显示                               OK (3) 动画效果 (4) 过一段时间(2500)自动跳转到下一个页面     OK (5) 关闭自己                                                   OK (6) 后台操作(下载新图/检查网络/检查root) 课后作业: 实现欢

小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面

原文:http://blog.csdn.net/jkingcl/article/details/10989773 今天我们主要来介绍登陆页面的实现,主要讲解的就是涉及到的布局,以及简单的跳转需要用到的代码. 首先我们来看看布局的xml代码 login.xml [html] view plaincopy <span style="font-family:Arial;font-size:18px;"><?xml version="1.0" encodi

Android 模仿QQ风格的 UI

本文内容 环境 演示模仿QQ风格的界面 本文主要演示的是 UI,如何模仿 QQ 风格的界面. 下载 Demo 环境 Windows 2008 R2 64 位 Eclipse ADT V22.6.2,Android 4.4.3 SAMSUNG GT-I9008L,Android OS 2.2.2   演示模仿QQ风格的 UI   程序启动时,有一个启动动画,如图 1 所示.之后进入登录页面,如图 2 所示,点击"登录"按钮后,进入主程序界面. 图 1 启动动画 图 2 登录界面和点击&q

Android HttpClient自动登陆discuz论坛!

你登陆论坛的时候,我们先看看浏览器干了什么事儿: 用Firefox打开HiPda 的登陆页面,输入用户名和密码,点登陆. 下面是通过firebug插件获取的数据: 可以看到浏览器这个http://www.hi-pda.com/forum/logging.php?action=login&loginsubmit=yes&inajax=1网址发了一个POST请求 看一下它POST的参数是什么: 可以看到一共有7个参数: 第一个cookietime=259200,这个是固定的,直接传这个值过去就