//{后缀名, MIME类型}
{".3gp", "video/3gpp"},
{".apk", "application/vnd.android.package-archive"},
{".asf", "video/x-ms-asf"},
{".avi", "video/x-msvideo"},
{".bin", "application/octet-stream"},
{".bmp", "image/bmp"},
{".c", "text/plain"},
{".class", "application/octet-stream"},
{".conf", "text/plain"},
{".cpp", "text/plain"},
{".doc", "application/msword"},
{".exe", "application/octet-stream"},
{".gif", "image/gif"},
{".gtar", "application/x-gtar"},
{".gz", "application/x-gzip"},
{".h", "text/plain"},
{".htm", "text/html"},
{".html", "text/html"},
{".jar", "application/java-archive"},
{".java", "text/plain"},
{".jpeg", "image/jpeg"},
{".jpg", "image/jpeg"},
{".js", "application/x-javascript"},
{".log", "text/plain"},
{".m3u", "audio/x-mpegurl"},
{".m4a", "audio/mp4a-latm"},
{".m4b", "audio/mp4a-latm"},
{".m4p", "audio/mp4a-latm"},
{".m4u", "video/vnd.mpegurl"},
{".m4v", "video/x-m4v"},
{".mov", "video/quicktime"},
{".mp2", "audio/x-mpeg"},
{".mp3", "audio/x-mpeg"},
{".mp4", "video/mp4"},
{".mpc", "application/vnd.mpohun.certificate"},
{".mpe", "video/mpeg"},
{".mpeg", "video/mpeg"},
{".mpg", "video/mpeg"},
{".mpg4", "video/mp4"},
{".mpga", "audio/mpeg"},
{".msg", "application/vnd.ms-outlook"},
{".ogg", "audio/ogg"},
{".pdf", "application/pdf"},
{".png", "image/png"},
{".pps", "application/vnd.ms-powerpoint"},
{".ppt", "application/vnd.ms-powerpoint"},
{".prop", "text/plain"},
{".rar", "application/x-rar-compressed"},
{".rc", "text/plain"},
{".rmvb", "audio/x-pn-realaudio"},
{".rtf", "application/rtf"},
{".sh", "text/plain"},
{".tar", "application/x-tar"},
{".tgz", "application/x-compressed"},
{".txt", "text/plain"},
{".wav", "audio/x-wav"},
{".wma", "audio/x-ms-wma"},
{".wmv", "audio/x-ms-wmv"},
{".wps", "application/vnd.ms-works"},
//{".xml", "text/xml"},
{".xml", "text/plain"},
{".z", "application/x-compress"},
{".zip", "application/zip"},
{"", "*/*"}
先说一下需求,我有多个tab页,每个tab也有新数据时我要动态提示是那个tab页收到了新数据。
我采用的继承TabActivity然后用
.addTab(myTabhost.newTabSpec("Sex")// make a new Tab
.setIndicator("首页",getResources().getDrawable(R.drawable.a_1))
// set the Title and Icon
.setContent(new Intent(this,HomeActivity.class)));
然后我采用的是线程来控制,改变tab页text的颜色
private TabHost myTabhost;
private final int START=1;
private Message msg;
private TextView tv;
new Thread(new Runnable() {
@Override
public void run() {
while(true){
try {
msg = Message.obtain();
msg.what = 1;
handler.sendMessage(msg);
Thread.sleep(500);
//不停切换
} catch (InterruptedException e) {
}
}
}
}).start();
private final Handler handler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case START:
TabHost host=getTabHost();
TabWidget widget=host.getTabWidget();
tv = (TextView) widget.getChildAt(2).findViewById(android.R.id.title);//这儿getChildAt(2)是选择的第三个tab页进行提示,这儿可以动态给值
String r=decToHex((int)Math.floor(Math.random()*256)-1);
String g=decToHex((int)Math.floor(Math.random()*256)-1);
String b=decToHex((int)Math.floor(Math.random()*256)-1);
tv.setTextColor(Color.parseColor("#"+r+g+b));
break;
}
}
};
public String decToHex(int dec)
{
String hexStr = "0123456789ABCDEF";
int low = Math.abs(dec % 16);
int high = Math.abs((dec - low)/16);
String hex = "" + (hexStr.length()>high?hexStr.charAt(high):hexStr.charAt(0)) + (hexStr.length()>low?hexStr.charAt(low):hexStr.charAt(10));
return hex;
}
[[NSDate date] timeIntervalSinceDate:preLocationDate] > 60.0fNSTimeInterval返回的是一个double值,单位是秒