8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
package com.m520it.weatherparse;
import java.io.InputStream;
import org.xmlpull.v1.XmlPullParser;
import android.app.Activity;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.util.Xml;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//
Button parseWeatherBtn = (Button) findViewById(R.id.parseweather_btn);
final TextView dispalyTv = (TextView) findViewById(R.id.display_tv);
parseWeatherBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String info = null;
try {
info = usePull2ParseWeather();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dispalyTv.setText(info);
}
});
}
protected String usePull2ParseWeather() throws Exception {
String string = "";
//1、获取asserts中的文件
AssetManager assetManager = getAssets();
//2、创建一个流,指向weather.xml
InputStream is = assetManager.open("weather.xml");
//3、创建一个pull解析器,并打开weather.xml
XmlPullParser newPullParser = Xml.newPullParser();
newPullParser.setInput(is, "utf-8");
//4、获取标签状态
int eventType = newPullParser.getEventType();
//5、循环来取值
while(eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG
&&newPullParser.getName().equals("string")) {
//这里注意字符串的比较一定要用equals()方法
string += newPullParser.nextText()+"n";
}
eventType = newPullParser.next();
}
return string;
}
}
activity_main.xml
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:id="@+id/parseweather_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/parse_weather" />
android:id="@+id/display_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
assets/weather.xml
这个是被解析的文件,存放在assets文件夹下
北京
2015-9-7 15:22:46
17℃/29℃
无持续风向微风
今日天气实况:气温:28℃;风向/风力:西南风 2级;湿度:44%;空气质量:暂无;紫外线强度:强