Reputation: 1946
when i run
msgcheck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(msgcheck.isChecked()){
//hedearMsg
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setContentView(R.layout.custommsg);
dialog.setCancelable(true);
dialog.show();
Thread t = new Thread() {
public void run() {
// Do something on another thread
PopulatePeopleList();
}
};
t.run();
}
});
my program hang a few second and then show dialog
i want run this dialog without hanging and PopulatePeopleListfunc work anyone idea?
Upvotes: 1
Views: 91
Reputation: 36289
A third option would be to use a Runnable
, which can be constructed within the thread, or elsewhere:
new Thread(new Runnable()
{
@Override
public void run()
{
PopulatePeopleList();
}
}).start();
Upvotes: 0
Reputation: 62459
Threads are started with start
, not run
:
Thread t = new Thread() {
public void run() {
// Do something on another thread
PopulatePeopleList();
}
};
t.start();
run
will just call the run
method sequentially on the main thread.
Upvotes: 3