标签:match 消息 cti tools etc main 主页 task 除了
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="35dp"
android:id="@+id/tv_test"/>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
private TextView tv_test;
String test[] = new String[]{
"1", "2", "3", "4", "5", "6", "7", "8", "9"
};
int numStart = 0;
Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if (msg.what == 0x123) {
tv_test.setText(test[numStart++%9]);
Log.d("MainActivity", "numStart:" + numStart);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
handler.sendEmptyMessage(0x123);
}
},0,1000);
}
private void initView() {
tv_test = (TextView) findViewById(R.id.tv_test);
}
}
标签:match 消息 cti tools etc main 主页 task 除了
原文地址:https://www.cnblogs.com/ldy731729142/p/14231541.html