How to update UI using AsyncTask?

Use onProgressUpdate() method of AsyncTask. It is performed on UI thread.

Try Asynctask as shown here: try{ class test extends AsyncTask{ TextView tv_per; int mprogress; Dialog UpdateDialog = new Dialog(ClassContext); @Override protected void onPreExecute() { // TODO Auto-generated method stub mprogress = 0; UpdateDialog. SetTitle(getResources(). GetString(R.string.

App_name)); UpdateDialog. SetContentView(R.layout. Horizontalprogressdialog); TextView dialog_message = (TextView)UpdateDialog.

FindViewById(R.id. TitleTvLeft); tv_per = (TextView)UpdateDialog. FindViewById(R.id.

Hpd_tv_percentage); dialog_message. SetText(getResources(). GetString(R.string.

Dialog_retrieving_data)); dialog_message. SetGravity(Gravity. RIGHT); UpdateDialog.

SetCancelable(false); UpdateDialog.show(); super.onPreExecute(); } @Override protected void onProgressUpdate(Object... values) { // TODO Auto-generated method stub ProgressBar update = (ProgressBar)UpdateDialog. FindViewById(R.id. HorizontalProgressBar); update.

SetProgress((Integer) values0); int percent = (Integer) values0; if(percent>=100) { percent=100; } tv_per = (TextView)UpdateDialog. FindViewById(R.id. Hpd_tv_percentage); tv_per.

SetText(""+percent); } @Override protected Object doInBackground(Object... params) { // TODO Auto-generated method stub //your code of UI operation } super. OnPostExecute(result); UpdateDialog.dismiss(); } } new test(). Execute(null); } catch(Exception e) { e.printStackTrace(); } Also refer to this link: Fetch data from server and refresh UI when data is fetched?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions