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.
- Code: Select all
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);
}
};
Thank you in advance!


