0
我使用一個機器人項目作爲我的理解一個參考,在那裏,我發現這個界面:什麼是HttpCallback <T>中的目的和什麼是T?
public interface HttpCallback<T> {
void onSuccess(T var1);
void onHttpError(ResponseStatus var1);
}
我Main Activity
它實現了HttpCallback<UserDetails>
參照此接口。
我的問題是,我不能得到什麼是T?請建議我在HttpCallback<T>
代表什麼是T
。
//主要活動代碼:
public class MainActivity extends HttpCallback<UserDetails> {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
}
HttpCallback<UserDetails> userDetailCallback = new HttpCallback<UserDetails>() {
@Override
public void onSuccess(UserDetails userDetails) {
setProgressVisibility(R.id.button_find_user, View.INVISIBLE);
if(!"ok".equals(addressDetails.errorMsg)){
showErrorMessage("UserDetails Error", userDetails.errorMsg);
return;
}
}
@Override
public void onHttpError(ResponseStatus responseStatus) {
setProgressVisibility(R.id.button_find_user, View.INVISIBLE);
showErrorMessage("Internet Connection Problem", "Please check your Internet connection then try again.");
}
};
}
謝謝。
閱讀上Java泛型:HTTP:/ /stackoverflow.com/questions/15888551/how-to-interpret-public-tt-readobjectdata-classt-type-in-java – rafid059
閱讀:https://docs.oracle.com/javase/tutorial/java/generics/types .html –
謝謝@AshshinGhazi –