您能告诉我为什么我无法点击onCreate() {
...
getNewsItems(new NewsItemsListener() {
void onFetched(ArrayList<NewsItems> items) {
// Do whatever you want to do with your news items
}
});
}
public void getNewsItems(final NewsItemsListener listener)
new AsyncTask<Void, Void, ArrayList<NewsItems>>() {
@Override
protected ArrayList<NewsItems> doInBackground(Void... params) {
ArrayList<NewsItems> response = whatEverMethodGetsMeNetworkCallResponse();
return response;
}
@Override
protected void onPostExecute(ArrayList<NewsItems> response) {
super.onPostExecute(response);
listener.onFetched(response);
}
}.execute();
}
public interface NewsItemsListener {
void onFetched(ArrayList<NewsItems> items);
}
+
var dayLength = 1000*3600*24;
var current = new Date();
console.log(current);
$('button').on('click', function(){
var a = new Date((new Date()).valueOf() + dayLength);
console.log(a);
});
答案 0 :(得分:1)
您将dayLength
添加到new Date()
这是当前日期。您应该将其添加到current
变量。
var dayLength = 1000*3600*24;
var current = new Date();
console.log(current);
$('button').on('click', function(){
current = new Date(current.getTime() + dayLength);
console.log(current);
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn btn-default">+</button>
&#13;
请注意,我还将valueOf
更改为getTime
,因为每docs,通常不会在用户代码中调用valueOf
。