I am trying to view ProgressBar of Spinner style while loading array after button is clicked, The problem is : when OnClickListener is runing all the GUI is freezing and the setVisibility command Not working until the memory loading finish.
I tryd to use runOnUiThread or invalidate the gui and nothing is working |:
Please Help ?
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
spinner.setVisibility(View.VISIBLE); // <-- the spinner progressBar
loadPhoneMembers(); // <-- memory loading progress
Intent intent = new Intent();
intent.setClass(CreateFrom.this,CreateSendListFromPhoneContacts.class);
startActivity(intent);
}
});
You should move your loadPhoneMembers() method to a new thread since it is a time consuming process that is blocking the UI thread. For example, you could create a class that extends AsyncTask
and move this code to the doInBackground()
method of this class. Here is the documentation: http://developer.android.com/reference/android/os/AsyncTask.html
Note that you can not make changes to the user interface from a background thread
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.