摘要:
this.getResources().getString(R.string.activity_main_port);如果要获取values目录下自定义的xml文件中的数据如获取string-arrayString[] incomeItems = getResources().getStringArray(R.array.income_placeholder); 阅读全文
摘要:
public JSONObject urlConn(String urlStr, String portStr){ String port = getPort(portStr); urlStr = (urlStr != null)?(host + port + "/?" + urlStr):(host + port); int responseCode;try { url = new URL(urlStr); conn = (HttpURLConnection) url.openConnection(); responseCode = conn.getResponseCod 阅读全文
摘要:
JSONArray jsonArr = jsonData.getJSONArray("gameList"); for (int i = 0; i < jsonArr.length(); i++) { String regionStr = ((JSONObject) jsonArr.opt(i)) .getString("language") + " " + ((JSONObject) jsonArr.opt(i)).getString("platform") + " " + ((JSONO 阅读全文
摘要:
private LinearLayout activity_view = null;// 获得一个可扩展的layout实例 private LayoutInflater inflater = null;activity_view = (LinearLayout) findViewById(R.id.activity_view);inflater = (LayoutInflater) MainActivity.this .getSystemService(LAYOUT_INFLATER_SERVICE);// 将layout添加到view View view = inflater.inflate 阅读全文
摘要:
/** * 加载notification内容 */ private void loadNotifiListView() { notifiListView = (ListView) findViewById(R.id.notifi_list); ArrayList list = new ArrayList(); HashMap map; map = new HashMap(); map.put("id", 1); map.put("notiIcon", R.drawable.ic_launcher); map.put("notiInfo" 阅读全文
摘要:
/** * 获取游戏列表数据 */ private void getGameListData(String urlStr, String portStr) { ArrayList list = new ArrayList(); HashMap map; HttpConn httpConn = new HttpConn(); JSONObject jsonData = httpConn.urlConn(urlStr, portStr); try { JSONArray jsonArr = jsonData.getJSONArray("gameList"); for (int 阅读全文
摘要:
/** * 初始化spinner下的内容 */ private void addSpinnerItem() { ArrayAdapter<String> adapter; adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, words); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); wordSpinner.setAdapter(adapter); ad 阅读全文
摘要:
package com;/* * 生产类 */public class Producer implements Runnable { //开始操作数据存储类P P q = null; public Producer(P q){ this.q = q; }@Override public void run() { int i = 0; while(true){ //编写往数据存储空间放入数据的代码 if( i == 0 ){ q.set("张三", "男"); }else{ q.set("李四", "女"); } i 阅读全文