I want change TextView content to the result of calculation in thread, but crashing when execution. Here's my code.
new Thread(new Runnable() {
public void run() {
while (i < 5) {
i++;
}
getActivity().runOnUiThread(new Runnable() {
public void run() {
TextView txv = (TextView) getView().findViewById(R.id.txvone);
Log.d("123","i = "+ i);
txv.setText(i);//CRASH!!!
}
});
}
}).start();