In my application , i have 3 buttons A,B,C . on the press of button A, i am doing some computations that takes some time … in that period , i want to disable the other two buttons. I am providing the code for the onClick listener for one button..
case R.id.buttona:
//Disabling other two buttons
start1b.setVisibility(v.INVISIBLE);
start1c.setVisibility(v.INVISIBLE);
stop1.setVisibility(v.INVISIBLE);
//this is the process that takes time
String x ="/databank/Reading18.wav";
timedata1a = fe.returningtimedata(x);
rawdata1a = fe.returningrawdata(x);
Log.d("now press", "button");
//features of Reading 1 hav been extracted into timedata1a
start1b.setVisibility(v.VISIBLE);
start1c.setVisibility(v.VISIBLE);
stop1.setVisibility(v.VISIBLE);
break;
but when i press 1 button A and then immediately press button B , the application force closes .. can any1 help ??
you need to perform operations which you want to perform in disabled state in other thread than UI. cause event thread never gets time to disable the buttons. so You can do following:
You need to define a handler to post results back to UI thread after thread processiing completes.