我創建這個方法/函數,我需要實現回調。我的意思是,我需要添加一個動態參數,一個函數。 我已經閱讀了幾篇文章,但我無法理解如何得到它。 任何想法或使用的例子?如何創建回調(添加爲動態參數,函數)?
public void httpReq (final String url, final Object postData, String callbackFunct, Object callbackParam,String callbackFailFunct) {
if (postData == null || postData == "") {
//GET
Thread testGET = new Thread(new Runnable() {
@Override
public void run() {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
....
}
}
} else {
//POST
Thread testPOST = new Thread(new Runnable() {
@Override
public void run() {
HttpGet httpPost = new HttpPost(url);
....
}
}
}
}
此代碼已經嚇到我了。希望你只是在你的帖子中使用它。 –
對GoT用戶名+1和小傢伙路由 –