安卓实训第三天---简单的用户登录界面,用HTTPURLConnection实现与服务器的连接

Android命令:adb devices adb -emulator相对布局完成login界面以及已经被弃用的绝对布局:运用相对布局来完成操作marginright 两个之间有一定的像素toRightof 是在他右面不允许子线程来改变主线程的操作通过Handler来完成这个操作。土司效果也一样
摘要由CSDN通过智能技术生成
Android命令:
adb devices 
adb -emulator

相对布局完成login界面以及已经被弃用的绝对布局:
运用相对布局来完成操作
marginright 两个之间有一定的像素
toRightof 是在他右面

不允许子线程来改变主线程的操作
通过Handler来完成这个操作。
土司效果也一样
当你使用GET方法时,需要在final String userName = URLEncoder.encode(et_name.getText().toString(), "UTF-8");一开始就设置好,这样就能够实现中文用户名的登录。
当你使用POST方法时,需要在服务器端的SERVLET中加上request.setCharacterEncoding("UTF-8");
 
 

Class Overview


A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

There are two main uses for a Handler: (1) to schedule messages and runnables to be executed as some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.

Scheduling messages is accomplished with the post(Runnable), postAtTime(Runnable, long), postDelayed(Runnable, long), sendEmptyMessage(int), sendMessage(Message), sendMessageAtTime(Message, long), and sendMessageDelayed(Message, long) methods. The post versions allow you to enqueue Runnable objects to be called by the message queue when they are received; the sendMessage versions allow you to enqueue a Message object containing a bundle of data that will be processed by the Handler's handleMessage(Message) method (requiring that you implement a subclass of Handler).

When posting or sending to a Handler, you can either allow the item to be processed as soon as the message queue is ready to do so, or specify a delay before it gets processed or absolute time for it to be processed. The latter two allow you to implement timeouts, ticks, and other timing-based behavior.

When a process is created for your application, its main thread is dedicated to running a message queue that takes care of managing the top-level application objects (activities, broadcast receivers, etc) and any windows they create. You can create your own threads, and communicate back with the main application thread through a Handler. This is done by calling the same post or sendMessage methods as before, but from your new thread. The given Runnable or Message will then be scheduled in the Handler's message queue and processed when appropriate.

类概述


A处理允许你发送和处理消息并与线程的相关Runnable对象的MessageQueue每个处理程序实例都与一个单独的线程和线程的消息队列相关联。当你创建一个新的处理程序,它必然要被创建它的线程的线程/消息队列-从这一点上来说,它将提供信息和可运行到该消息队列并执行他们,因为他们出来的消息排队。

有一个处理器两个主要用途:(1)在未来的某一时刻要执行调度信息和可运行; 及(2)入队要在不同的线程比你自己执行的操作。

调度信息是通过该 职位(运行)postAtTime(Runnable的,长), postDelayed(Runnable的,长)sendEmptyMessage(INT) , 的sendMessage(消息)sendMessageAtTime(消息,长),并 sendMessageDelayed(消息,长)的方法。职位的版本让你排队Runnable对象通过消息队列调用收到时; 的sendMessage版本允许您排队一个

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值