我正在阅读AsyncTask,我尝试了下面的简单程序.但它似乎没有用.我怎样才能使它工作?
public class AsyncTaskActivity extends Activity {
Button btn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener((OnClickListener) this);
}
public void onClick(View view){
new LongOperation().execute("");
}
private class LongOperation extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
for(int i=0;i<5;i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
TextView txt = (TextView) findViewById(R.id.output); …Run Code Online (Sandbox Code Playgroud) 在App Engine文档中,JID...此方法签名中的省略号()是什么?
public MessageBuilder withRecipientJids(JID... recipientJids)
Run Code Online (Sandbox Code Playgroud)
这三个点的功能是什么?
有一个Java Void- 大写的V-- 引用类型.我见过它唯一的情况是参数化Callables
final Callable<Void> callable = new Callable<Void>() {
public Void call() {
foobar();
return null;
}
};
Run Code Online (Sandbox Code Playgroud)
Java Void引用类型还有其他用途吗?可以分配除了以外的任何东西null吗?如果是的话,你有例子吗?