利用课余时间随便写的一个小东西,都是一起学习。

先上图:

package com.example.nanchen.listviewdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView; import com.example.nanchen.listviewdemo.adapter_content.Msg;
import com.example.nanchen.listviewdemo.R; import java.util.List; /**
* Created by nanchen on 2016/3/28.
*
*/
public class MsgAdapter extends ArrayAdapter<Msg> {
private int resourceId; public MsgAdapter(Context context, int resource, List<Msg> objects) {
super(context, resource, objects);
resourceId = resource;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
Msg msg = getItem(position);
viewHolder viewHolder;
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(resourceId,null);
viewHolder = new viewHolder();
viewHolder.leftLayout = (LinearLayout) convertView.findViewById(R.id.left_layout);
viewHolder.rightLayout = (LinearLayout) convertView.findViewById(R.id.right_layout);
viewHolder.leftMsg = (TextView) convertView.findViewById(R.id.left_msg);
viewHolder.rightMsg = (TextView) convertView.findViewById(R.id.right_msg);
convertView.setTag(viewHolder);
}else{
viewHolder = (MsgAdapter.viewHolder) convertView.getTag();
}
if (msg.getType() == Msg.TYPE_RECEIVED){//若是收到的消息,则隐藏右布局,显示左布局
viewHolder.leftLayout.setVisibility(View.VISIBLE);
viewHolder.rightLayout.setVisibility(View.GONE);
viewHolder.leftMsg.setText(msg.getContent());
}else if(msg.getType() == Msg.TYPE_SENT){
viewHolder.leftLayout.setVisibility(View.GONE);
viewHolder.rightLayout.setVisibility(View.VISIBLE);
viewHolder.rightMsg.setText(msg.getContent());
}
return convertView;
}
class viewHolder{
LinearLayout leftLayout;
LinearLayout rightLayout;
TextView leftMsg;
TextView rightMsg;
}
}

  

package com.example.nanchen.listviewdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView; import com.example.nanchen.listviewdemo.adapter_content.Person;
import com.example.nanchen.listviewdemo.R; import java.util.List; /**
*
* Created by nanchen on 2016/3/22.
*/
public class PersonAdapter extends ArrayAdapter<Person> { private int resourceId; public PersonAdapter(Context context, int textViewResourceId, List<Person> objects) {
super(context, textViewResourceId, objects);
resourceId = textViewResourceId;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
Person person = getItem(position);
ViewHolder viewHolder;
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(resourceId ,null);
viewHolder = new ViewHolder();
viewHolder.imageView_person = (ImageView) convertView.findViewById(R.id.imageView_person);
viewHolder.textView_name = (TextView) convertView.findViewById(R.id.textView_name);
convertView.setTag(viewHolder);
}else{
// view = convertView;
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.imageView_person.setImageResource(person.getImageId());
viewHolder.textView_name.setText(person.getName());
return convertView;
} class ViewHolder{
ImageView imageView_person;
TextView textView_name;
}
}
package com.example.nanchen.listviewdemo.adapter_content;

/**
* Created by nanchen on 2016/3/28.
* 存储消息类型和内容的类
*/
public class Msg {
public static final int TYPE_RECEIVED = 0;
public static final int TYPE_SENT = 1;
private String content;
private int type; public Msg(String content, int type) {
this.content = content;
this.type = type;
} public String getContent() {
return content;
} public int getType() {
return type;
}
}
package com.example.nanchen.listviewdemo.adapter_content;

/**
* Created by nanchen on 2016/3/22.
*/
public class Person {
private String name;
private int imageId; public Person(String name, int imageId) {
this.name = name;
this.imageId = imageId;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getImageId() {
return imageId;
} public void setImageId(int imageId) {
this.imageId = imageId;
}
}
 package com.example.nanchen.listviewdemo.data;

 import android.os.Parcel;
import android.os.Parcelable; /**
*
* Created by nanchen on 2016/3/22.
*/
public class User implements Parcelable { private String userName;
private String pwd; public String getPwd() {
return pwd;
} public void setPwd(String pwd) {
this.pwd = pwd;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} @Override
public int describeContents() {
return 0;
} @Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(userName);
dest.writeString(pwd);
} //对象的创建器
public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>(){ @Override
public User createFromParcel(Parcel source) {
User user = new User();
user.userName = source.readString();
user.pwd = source.readString();
return user;
} @Override
public User[] newArray(int size) {
return new User[0];
}
};
}
 package com.example.nanchen.listviewdemo;

 import android.app.Activity;

 import java.util.ArrayList;
import java.util.List; /**
* Created by nanchen on 2016/3/28.
* 退出程序的最佳方案,写一个活动收集器
*/
public class ActivityCollector {
public static List<Activity> activities = new ArrayList<>(); public static void addActivity(Activity activity){
activities.add(activity);
} public static void removeActivity(Activity activity){
activities.remove(activity);
} public static void finishAll(){
for (Activity activity:activities){
if (!activity.isFinishing()){
activity.finish();
}
}
}
}
 package com.example.nanchen.listviewdemo;

 import android.app.Activity;
import android.os.Bundle;
import android.util.Log; /**
* Created by nanchen on 2016/3/28.
* 用于知晓当前是在哪一个活动
* 活动的最佳写法
*/
public class BaseActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("BaseActivity", getClass().getSimpleName());
ActivityCollector.addActivity(this);
} @Override
protected void onDestroy() {
super.onDestroy();
ActivityCollector.removeActivity(this);
}
}
package com.example.nanchen.listviewdemo;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast; import com.example.nanchen.listviewdemo.adapter.MsgAdapter;
import com.example.nanchen.listviewdemo.adapter_content.Msg; import java.util.ArrayList;
import java.util.List; public class ChatActivity extends BaseActivity { private ListView listView_msg;
private EditText editText_input;
private Button button_send,button_back,button_add;
private MsgAdapter msgAdapter;
private List<Msg> msgList = new ArrayList<>();
private TextView textView_person_name; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat); initMsg();
msgAdapter = new MsgAdapter(this,R.layout.msg_item,msgList);
listView_msg = (ListView) findViewById(R.id.listView_msg);
listView_msg.setAdapter(msgAdapter); editText_input = (EditText) findViewById(R.id.editText_send);
editText_input.clearFocus();
button_send = (Button) findViewById(R.id.button_send);
button_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String content = editText_input.getText().toString();
if(content.isEmpty()){//用户输入消息为空,则弹出一个警告框
final AlertDialog.Builder builder = new AlertDialog.Builder(ChatActivity.this);
builder.setTitle("警告");
builder.setMessage("输入的消息不能为空!");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}else{
Msg msg = new Msg(content,Msg.TYPE_SENT);
msgList.add(msg);
msgAdapter.notifyDataSetChanged();//当有新消息时,刷新ListView中的显示
listView_msg.setSelection(msgList.size());//将ListView定位到最后一行
editText_input.setText("");//清空输入框中的内容 }
}
}); button_back = (Button) findViewById(R.id.button_back);
button_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
button_add = (Button) findViewById(R.id.button_add);
button_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ChatActivity.this,"你点击了添加按钮!!!",Toast.LENGTH_SHORT).show();
}
}); textView_person_name = (TextView) findViewById(R.id.textView_person_name);
Intent intent = getIntent();
String person_name = intent.getStringExtra("PERSON_NAME");
textView_person_name.setText(person_name);
} private void initMsg() {
Msg msg = new Msg("Hello!",Msg.TYPE_SENT);
msgList.add(msg);
Msg msg1 = new Msg("Hello!How are you?",Msg.TYPE_RECEIVED);
msgList.add(msg1);
Msg msg2 = new Msg("I am fine,and you?",Msg.TYPE_SENT);
msgList.add(msg2);
Msg msg3 = new Msg("I am ok!",Msg.TYPE_RECEIVED);
msgList.add(msg3);
}
}
package com.example.nanchen.listviewdemo;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast; import com.example.nanchen.listviewdemo.data.User; public class LoginActivity extends BaseActivity { private EditText editText_userName,editText_pwd;
private CheckBox checkBox_pwd,checkBox_autoLogin;
private SharedPreferences sp;
private ImageButton imageButton_exit;
private Button button_login;
private String userName,pwd;
private Button button_regist; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); //获得实例对象
sp = this.getSharedPreferences("userInfo", Context.MODE_PRIVATE);
editText_userName = (EditText) findViewById(R.id.editText_userName);
editText_pwd = (EditText) findViewById(R.id.editText_pwd);
imageButton_exit = (ImageButton) findViewById(R.id.ib_exit);
button_login = (Button) findViewById(R.id.button_login);
checkBox_autoLogin = (CheckBox) findViewById(R.id.checkBox_autoLogin);
checkBox_pwd = (CheckBox) findViewById(R.id.checkBox_pwd);
button_regist = (Button) findViewById(R.id.button_regist1); //判断记住密码框状态
if(sp.getBoolean("ISCHECK",false)){//false是默认值
//设置默认是选择状态
checkBox_pwd.setChecked(true);
userName = sp.getString("USER_NAME","");
pwd = sp.getString("PWD","");
editText_userName.setText(userName);
editText_pwd.setText(pwd); //判断自动登录复选框状态
if(sp.getBoolean("AUTO_ISCHECK",false)){ //设置自动登录框状态
checkBox_autoLogin.setChecked(true); Intent intent = new Intent(LoginActivity.this,MainActivity.class);
startActivity(intent);
}
} button_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
userName = editText_userName.getText().toString();
pwd = editText_pwd.getText().toString(); if(TextUtils.isEmpty(userName) || TextUtils.isEmpty(pwd)){//如果用户名或者密码为空
Toast.makeText(LoginActivity.this, "用户名或密码不能为空!", Toast.LENGTH_SHORT).show();
}else {
if(userName.equals("liushilin") && pwd.equals("luochunyan")){
Toast.makeText(LoginActivity.this,"登录成功!正在获取用户信息...",Toast.LENGTH_SHORT).show(); //如果用户选择记住密码,则把用户信息存在xml文件中
if(checkBox_pwd.isChecked()){
SharedPreferences.Editor editor = sp.edit();
editor.putString("USER_NAME",userName);
editor.putString("PWD",pwd);
editor.commit();
} //主界面的跳转
Intent intent = new Intent(LoginActivity.this,MainActivity.class); // intent.putExtra("USER_NAME",userName);
// intent.putExtra("PWD",pwd); User user = new User();
user.setUserName(userName);
user.setPwd(pwd); intent.putExtra("USER",user); startActivity(intent);
}else{
Toast.makeText(LoginActivity.this,"用户名或密码不正确,请重新输入!",Toast.LENGTH_SHORT).show();
}
}
}
}); //监听记住密码复选框的按钮事件
checkBox_pwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = sp.edit();
if(checkBox_pwd.isChecked()){
editor.putBoolean("ISCHECK", true).commit();
}else{
editor.putBoolean("ISCHECK",false).commit();
} }
}); //监听自动登录按钮事件
checkBox_autoLogin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(checkBox_autoLogin.isChecked()){
sp.edit().putBoolean("AUTO_ISCHECK",true).commit();
}else {
sp.edit().putBoolean("AUTO_ISCHECK",false).commit();
}
}
}); //监听退出按钮事件
imageButton_exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// finish();
ActivityCollector.finishAll();//退出当前应用程序
}
}); button_regist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this,RegistActivity.class));
}
});
} }

  

package com.example.nanchen.listviewdemo;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView; import com.example.nanchen.listviewdemo.adapter.PersonAdapter;
import com.example.nanchen.listviewdemo.adapter_content.Person; import java.util.ArrayList;
import java.util.List; /**
* 使用线程机制模拟下拉加载数据的ListView控件使用
*/
public class MainActivity extends BaseActivity implements AbsListView.OnScrollListener{
private static final int DATA_UPDATE = 0x1;
private ListView listView;
private List<Person> personList = new ArrayList<>();
private PersonAdapter personAdapter; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.listView);
listView.setOnScrollListener(this); View footerView = getLayoutInflater().inflate(R.layout.loading_layout,null);
listView.addFooterView(footerView);
initData(); personAdapter = new PersonAdapter(this,R.layout.list_item,personList);
listView.setAdapter(personAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Toast.makeText(MainActivity.this,"你选择了"+personList.get(position).getName(),Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this,ChatActivity.class);
intent.putExtra("PERSON_NAME",personList.get(position).getName());
startActivity(intent);
}
}); } /**
* 初始化数据
*/
private void initData(){
Person person1 = new Person("刘世麟",R.mipmap.a_1);
personList.add(person1);
Person person2 = new Person("罗春燕",R.mipmap.a_2);
personList.add(person2);
Person person3 = new Person("王足英",R.mipmap.a_3);
personList.add(person3);
Person person4 = new Person("蔡何",R.mipmap.a_4);
personList.add(person4);
Person person5 = new Person("李兴",R.mipmap.a_5);
personList.add(person5);
Person person6 = new Person("李强",R.mipmap.a_6);
personList.add(person6);
Person person7 = new Person("李添顺",R.mipmap.a_7);
personList.add(person7);
Person person8 = new Person("晏贵秀",R.mipmap.a_8);
personList.add(person8);
Person person9 = new Person("周芳",R.mipmap.a_9);
personList.add(person9);
Person person10 = new Person("韩思明",R.mipmap.a_10);
personList.add(person10);
Person person11 = new Person("晏蜀杰",R.mipmap.a_11);
personList.add(person11);
Person person12 = new Person("马巍乃",R.mipmap.a_12);
personList.add(person12);
} private int visibleLastIndex;//用来可显示的最后一条数据的索引
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if(personAdapter.getCount() == visibleLastIndex && scrollState == SCROLL_STATE_IDLE){
new LoadDataThread().start();
}
} @Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
visibleLastIndex = firstVisibleItem + visibleItemCount - 1;//减去最后一个加载中那条
} /**
* 线程间通信的机制
*/
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what){
case DATA_UPDATE:
personAdapter.notifyDataSetChanged();
break;
}
}
}; /**
* 模拟加载数据的线程
*/
class LoadDataThread extends Thread{
@Override
public void run() {
initData();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.sendEmptyMessage(DATA_UPDATE);//通过handler发送一个更新数据的标记
}
} }

  

package com.example.nanchen.listviewdemo;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button; public class RegistActivity extends BaseActivity { private Button button_regist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_regist);
button_regist = (Button) findViewById(R.id.button_regist);
button_regist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(RegistActivity.this);
builder.setTitle("注册");
builder.setMessage("确认注册吗?");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(RegistActivity.this, LoginActivity.class));
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(RegistActivity.this, LoginActivity.class));
}
});
builder.show();
}
});
}
}

  

package com.example.nanchen.listviewdemo;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler; public class SplashActivity extends BaseActivity { // private static final int STATR_ACTIVITY = 0x1; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// handler.sendEmptyMessageDelayed(STATR_ACTIVITY,2000);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashActivity.this,LoginActivity.class));
}
},3000); } // private Handler handler = new Handler(){
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
// switch(msg.what){
// case STATR_ACTIVITY:
// startActivity(new Intent(SplashActivity.this,LoginActivity.class));
// break;
// }
// }
// };
}

  

<?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:orientation="vertical"
tools:context="com.example.nanchen.listviewdemo.ChatActivity"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1"> <Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back"
android:textAllCaps="false"
android:id="@+id/button_back"/> <TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/textView_person_name"
android:layout_weight="4"
android:gravity="center"
/> <Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+"
android:textSize="18dp"
android:id="@+id/button_add"/> </LinearLayout> <ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:id="@+id/listView_msg"> </ListView> <LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="0dp"> <EditText
android:layout_width="0dp"
android:layout_weight="3"
android:id="@+id/editText_send"
android:hint="请输入你想输入的话.."
android:layout_height="wrap_content"/> <Button
android:layout_width="0dp"
android:layout_weight="1"
android:text="发送"
android:textSize="20dp"
android:id="@+id/button_send"
android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>

  

<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:orientation="vertical"
android:background="@mipmap/logo_bg"
tools:context=".LoginActivity"
android:weightSum="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.53"
> <ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ib_exit"
android:layout_alignParentRight="true"
android:src="@mipmap/quit"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用 户 名:"
android:textSize="18dp"
android:paddingTop="18dp"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_userName"
android:hint="请输入用户名..."
android:layout_below="@+id/textView"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/ib_exit"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密 码:"
android:textSize="18dp"
android:id="@+id/textView2"
android:layout_below="@+id/editText_userName"
android:layout_alignParentStart="true"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="请输入密码..."
android:ems="10"
android:id="@+id/editText_pwd"
android:layout_below="@+id/textView2"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"/> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记住密码"
android:id="@+id/checkBox_pwd"
android:checked="false"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_marginStart="27dp"/> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自动登录"
android:id="@+id/checkBox_autoLogin"
android:checked="false"
android:layout_below="@+id/checkBox_pwd"
android:layout_alignStart="@+id/checkBox_pwd"/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:id="@+id/button_login"
android:layout_alignBottom="@+id/checkBox_autoLogin"
android:layout_toEndOf="@+id/checkBox_pwd"
android:layout_marginStart="64dp"/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:id="@+id/button_regist1"
android:textAllCaps="false"
android:layout_alignTop="@+id/button_login"
android:layout_toEndOf="@+id/button_login"/> </RelativeLayout> </LinearLayout>

  

<?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:background="@mipmap/login_bg"
tools:context="com.example.nanchen.listviewdemo.MainActivity"> <ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:dividerHeight="3.1dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
/>
</RelativeLayout>

  

<?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:orientation="vertical"
android:background="@mipmap/login_bg"
tools:context="com.example.nanchen.listviewdemo.RegistActivity"> <LinearLayout
android:orientation="horizontal"
android:paddingTop="50dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="113dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="用户名:"
android:id="@+id/textView"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_name"
android:layout_weight="1"/>
</LinearLayout> <LinearLayout
android:orientation="horizontal"
android:paddingTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="113dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="密 码:"
android:id="@+id/textView3"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_weight="1"/>
</LinearLayout> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="完成注册"
android:id="@+id/button_regist"
android:layout_marginTop="42dp"
android:layout_below="@+id/linearLayout"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

  

<?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:background="@mipmap/app_start3"
tools:context="com.example.nanchen.listviewdemo.SplashActivity"> </RelativeLayout>

  

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:padding="6dp"
android:layout_height="match_parent"> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView_person"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView_name"/>
</LinearLayout>

  

<?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"> <ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="正在玩命加载中..."
android:id="@+id/textView"/>
</LinearLayout>

  

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:padding="6dp"
android:orientation="vertical"
android:layout_height="match_parent"> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/left_layout"
android:layout_gravity="left"
android:background="#c000dd"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/left_msg"
android:layout_margin="10dp"
android:textColor="#fff"
/> </LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/right_layout"
android:layout_gravity="right"
android:background="#00e6ff"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/right_msg"
android:layout_gravity="center"
android:layout_margin="10dp"/> </LinearLayout>
</LinearLayout>

  

模拟QQ聊天系统-安卓源代码的更多相关文章

  1. Android简易实战教程--第二十二话《自定义组合控件模拟qq登录下拉框和其中的一些”小技巧”》

    转载此文章请注明出处:点击打开链接   http://blog.csdn.net/qq_32059827/article/details/52313516 首先,很荣幸此专栏能被CSDN推荐到主页.荣 ...

  2. java 模拟qq源码

    java 模拟qq源码: http://files.cnblogs.com/files/hujunzheng/QQ--hjzgg.zip

  3. 利用phantomjs模拟QQ自动登录

    之前为了抓取兴趣部落里的数据,研究了下QQ自动登录. 当时搜索了一番,发现大部分方法都已经失效了,于是准备自己开搞. 第一个想到的就是参考网上已有方案的做法,梳理登陆js的实现,通过其他语言重写.考虑 ...

  4. 模拟QQ系统设置面板实现功能

    业务需求: 基于网盘客户端的实现,原有网盘的设置面板无论从界面显示还是从业务需求都不能满足我们的正常需求.当前的要求是,模拟QQ系统设置的面板实现当前我们网盘中的基本配置功能.在完成这篇文章时已将基本 ...

  5. WPF案例 (三) 模拟QQ“快速换装"界面

    原文:WPF案例 (三) 模拟QQ"快速换装"界面 这个小程序使用Wpf模拟QQ快速换装页面的动画特效,通过使用组合快捷键Ctrl+Left或Ctrl+Right,可实现Image ...

  6. 模拟QQ聊天与视频聊天同时进行-------java基础知识总结

    前言:多线程的知识 代码: package com.day13.math; /** * 类说明 :模拟QQ聊天与视频聊天同时进行 * @author 作者 : chenyanlong * @versi ...

  7. python模拟QQ聊天室(tcp加多线程)

    python模拟QQ聊天室(tcp加多线程) 服务器代码: from socket import * from threading import * s = socket(AF_INET,SOCK_S ...

  8. 判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备)

    判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备) // ===== 判断浏览器环境 ===== // // 判断是否是QQ环境 function isQQ() { retur ...

  9. 《AndroidStudio导入安卓源码-idegen》---可方便查看安卓源代码

    idegen是Android源码中的一个模块,需要编译一下.生成一个jar包.然后再进行构建生成AndroidStudio配置相关文件. > 什么是idegen 要将Android系统源代码工程 ...

随机推荐

  1. ArcGIS Server SOE开发之奇怪异常:

    添加之后结果显示如下:fjsontokenezkBvir0Tj5q31UEst7pTFPwrwocmHklCajKeh-xXM91qWdBXDuQMmtGcaHaaXCJ 具体如下: 该SOE扩展在另 ...

  2. DSY3163*Eden的新背包问题

    Description "寄没有地址的信,这样的情绪有种距离,你放着谁的歌曲,是怎样的心心静,能不能说给我听."失忆的Eden总想努力地回忆起过去,然而总是只能清晰地记得那种思念的 ...

  3. Unity3D 脚本手册

    1.private Ray ray;  --定义射线 ray = Camera.main.ScreenPointToRay(Input.mousePosition);  --摄像机发出的射线投射鼠标到 ...

  4. nodejs学习之events的使用

    实用events做个小例子: var mysql = require("mysql"); var Event = require("events").Event ...

  5. 带额外toggle()功能的jquery库

    <html><head><meta http-equiv="Content-Type" content="text/html;charset ...

  6. IE10(去掉文本框的X)

    input[type="text"]::-ms-clear{ display:none;}input[type="text"]::-ms-reveal{ dis ...

  7. SQL语句 多表基本操作

    创建四张表学生表:学号(Sno).姓名(Sname).性别(Ssex).年龄(Sage)教师表:教师编号(Tno).教师姓名(Tname)课程表:课程编号(Cno).课程名(Cname).教师编号(T ...

  8. .NET单元测试的艺术-3.测试代码

    开篇:上一篇我们学习单元测试和核心技术:存根.模拟对象和隔离框架,它们是我们进行高质量单元测试的技术基础.本篇会集中在管理和组织单元测试的技术,以及如何确保在真实项目中进行高质量的单元测试. 系列目录 ...

  9. Linux 定时任务

    200 ? "200px" : this.width)!important;} --> 介绍 本篇主要介绍Linux定时任务命令crontab的用法,crontab是定时任务 ...

  10. Docker实践:安装wordpress

    本文将示例如何使用Docker来安装wordpress.使用三种方法: 1.基于官方的wordpress镜像使用docker run实现: 2.基于官方的wordpress镜像使用fig命令编排工具实 ...