編輯:關於android開發
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/time"
android:layout_gravity="center_horizontal" />
</LinearLayout>
package com.example.yanlei.mytk;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity implements Runnable {
private Handler handler;
private TextView textView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView=(TextView) findViewById(R.id.time);
handler = new Handler() {
public void handleMessage(Message msg) {
textView.setText((String)msg.obj);
}
};
new Thread(this).start();
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
while(true){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String str=sdf.format(new Date());
handler.sendMessage(handler.obtainMessage(100,str));
Thread.sleep(1000);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Android源碼裝飾模式---ContextWrapper
Android源碼裝飾模式---ContextWrapper 如果說Android源碼中哪個地方裝飾模式應用的最明顯的話,那肯定是非ContextWrapper莫屬了
Android 善用Okio簡化處理I/O操作
Android 善用Okio簡化處理I/O操作 Okio庫是一個由square公司開發的,它補充了java.io和java.nio的不足,以便能夠更加方便,快速的訪問、
Android開發之Menu:OptionMenu(選項菜單)、ContextMenu(上下文菜單)、SubMenu(子菜單)
Android開發之Menu:OptionMenu(選項菜單)、ContextMenu(上下文菜單)、SubMenu(子菜單) 菜單的概念,現在已經很普及了。 W
Android:支持多選的本地相冊
Android:支持多選的本地相冊 前段時間在做一個動態發布功能,需要用到圖片上傳。一開始直接調用的系統相冊和相機,由於系統相機不支持多選,就花點時間做了個本地相冊,
Android Studio 優秀插件(二): Parcelable Code Generator,androidparcelable
Android Studio 優秀插件(二): Parcelable C