編輯:關於Android編程
/**
* 采用httpclientPost請求的方式
*
* @param username
* @param password
* @return null表示求得的路徑有問題,text返回請求得到的數據
*/
public static String httpclientPost(String username, String password) {
try {
// 1.打開一個浏覽器
HttpClient client = new DefaultHttpClient();
// 2.輸入地址
String path = "http://172.22.64.156:8080/0001AndroidWebService/LoginServlet";
HttpPost post = new HttpPost();
// 指定提交的數據實體
List parameters = new ArrayList();
parameters.add(new BasicNameValuePair("username", username));
parameters.add(new BasicNameValuePair("password", password));
post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
// 3,敲回車
HttpResponse response = client.execute(post);
// 獲取返回的碼
int code = response.getStatusLine().getStatusCode();
if (code == 200) {
// 獲取返回的信息
InputStream is = response.getEntity().getContent();
String text = StreamUtil.readStream(is);
return text;
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Android View控件的事件派發
引:一直想寫View,GroupView控件的事件派發流程.終於現在一口氣都寫出來.一鼓作氣!當然考慮了很久應該用怎麼樣的方式寫這些流程性的東西,應該用什麼用的語言來描述
Google推薦的圖片加載庫Glide介紹
在泰國舉行的谷歌開發者論壇上,谷歌為我們介紹了一個名叫Glide的圖片加載庫,作者是bumptech。這個庫被廣泛的運用在google的開源項目中,包括2014年goog
Android中的萬能適配器——base-adapter-helper解析
在Android開發中,我們經常會用到ListView、GridView,每次編碼的時候都需要為他們寫對應的Adapter,寫多了就感覺很煩躁了,因為基本的編程思想都是一
Android布局案例之人人android九宮格
人人android是人人網推出的一款優秀的手機應用軟件,我們在使用的時候發現他的首頁布局是九宮格模式的,讓人覺得很別致,因為現在很多的 android軟件很少使用這種布局