forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandlerActivity.java
More file actions
51 lines (42 loc) · 1.36 KB
/
HandlerActivity.java
File metadata and controls
51 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.blankj.androidutilcode.activity;
import android.app.Activity;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
import com.blankj.androidutilcode.R;
import com.blankj.utilcode.util.HandlerUtils;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/9/27
* desc : Handler工具类Demo
* </pre>
*/
public class HandlerActivity extends Activity
implements View.OnClickListener,
HandlerUtils.OnReceiveMessageListener {
private TextView tvAboutHandler;
private HandlerUtils.HandlerHolder handlerHolder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_handler);
tvAboutHandler = (TextView) findViewById(R.id.tv_about_handler);
findViewById(R.id.btn_send_msg_after_3s).setOnClickListener(this);
handlerHolder = new HandlerUtils.HandlerHolder(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_send_msg_after_3s:
handlerHolder.sendEmptyMessageDelayed(0, 3000);
break;
}
}
@Override
public void handlerMessage(Message msg) {
tvAboutHandler.setText("get_msg_after_3s");
}
}