Hi, Better use android asynctask (http://developer.android.com/reference/ android/os/AsyncTask.html)
Moktarul On Feb 17, 3:13 am, dc <[email protected]> wrote: > I am attempting to show a progress dialog while I am performing some > actions. I am having troubles getting it to perform the way I would > like. Here is what I want to do: > click event of a button > pop up a progress dialog showing a busy message. > perform some action > then once the action is complete, inflate a new layout into my main > layout. (changing screens) > It works fine except either I inflate the layout while the other > actions are still processing (layout change is outside the thread) or > if I put the layout change in the thread, it forces a close of the > app, at the layout.removeallviews; line. > > private OnClickListener feeAcceptListener = new OnClickListener() { > @Override > public void onClick(View v) { > progressBar = ProgressDialog.show(v.getContext(), "Please > Wait...","Communicating",true); > new Thread(new Runnable() { > @Override > public void run() { > GetWts(); //processes some action > progressBar.dismiss(); > } > }).start(); > > Handler handle=new Handler(){ > @Override > public void handleMessage(Message msg) { > super.handleMessage(msg); > > } > }; > LinearLayout layout = > (LinearLayout)findViewById(R.id.main_view); > layout.removeAllViews(); > LayoutInflater inflater = getLayoutInflater(); > layout.addView(inflater.inflate(R.layout.wts, null)); > > Button print = (Button)findViewById(R.id.btnPrintTic); > Button done= (Button)findViewById(R.id.btnDone); > print.setOnClickListener(wtsPrintListener); > done.setOnClickListener(wtsDoneListener); > } > }; -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

