編輯:關於Android編程
[java]
public static String test(String URL, List<BasicNameValuePair> params) {
HttpPost httpPost = new HttpPost(URL);
String returnString = "";
HttpParams httpParameters = new BasicHttpParams();
try {
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(
params, "utf-8");
httpPost.setEntity(urlEncodedFormEntity);
HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);
HttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream inputStream = httpEntity.getContent();
BufferedInputStream bufferedInputStream = new BufferedInputStream(
inputStream);
ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(50);
int current = 0;
while ((current = bufferedInputStream.read()) != -1) {
byteArrayBuffer.append(current);
}
returnString = EncodingUtils.getString(byteArrayBuffer
.toByteArray(), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return returnString;
} www.2cto.com
public static String test(String URL, List<BasicNameValuePair> params) {
HttpPost httpPost = new HttpPost(URL);
String returnString = "";
HttpParams httpParameters = new BasicHttpParams();
try {
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(
params, "utf-8");
httpPost.setEntity(urlEncodedFormEntity);
HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);
HttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream inputStream = httpEntity.getContent();
BufferedInputStream bufferedInputStream = new BufferedInputStream(
inputStream);
ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(50);
int current = 0;
while ((current = bufferedInputStream.read()) != -1) {
byteArrayBuffer.append(current);
}
returnString = EncodingUtils.getString(byteArrayBuffer
.toByteArray(), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return returnString;
}
作者:Etzmico
以下是開始Android編程的好方法: 1、找一些與你想開發的功能類似的代碼;  
一、簡述 最近項目組打算引入weex,並選定了一個頁面進行試水。頁面很簡單,主要是獲取數據渲染頁面,並可以跳轉到指定的頁面。跟之前使用RN 相比,weex 確實要簡單很
File file = new File(“hah.txt”);//只是創建了一個對象file, file指向了hah.txt這個文件,hah.t
現如今的APP各式各樣,同樣也帶來了各種需求,一個下拉刷新都能玩出花樣了,前兩天訂飯的時候不經意間看到了“百度外賣”的下拉刷新,今天的主題就是它–自定義下拉刷新動畫。看一