这是我的问题:
我知道如何发送短信,但我在这样的循环中使用它,而且我知道发送短信不好,所以我想添加一个延迟(即 1000 毫秒)。但是如何?
我想使用 ProgressDialog 来显示发送短信的进度。我知道我必须为此使用 Thread 或 AsyncTask。但我没有找到工作代码......
目前,我有这段代码,它并没有真正起作用:
Button sendButton = (Button) findViewById(R.id.sendButton);
sendButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
if (!studentList.isEmpty()) {
for (int i = 0; i < studentList.size(); i++) {
Student currentStudent = studentList.get(i);
currentStudent.sendSMS();
}
} else {
Toast.makeText(getApplicationContext(), "The list is empty.", Toast.LENGTH_SHORT).show();
}
}
});
如果您需要更多信息,请不要犹豫。
我想要一个工作示例代码之类的东西...
我是Java和Android开发的初学者,请记住开始有多么困难,请放纵!
问候, Drarig29。