Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Runnable Handler not executing inside fragment. Could not start a runnable without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
I have a runnable inside a fragment. The runnable is meant to update the textviews as well as receive input using buttons. But the program does not enter even once inside the runnable.
Please help. What am I doing wrong. Thanks. The code is as follows. I have buttons and textviews inside the runnable.
public class TodayFragment extends Fragment { //initialisations @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //UI initialisations Handler mHandler = new Handler(); Runnable mTicker = new Runnable() { @Override public void run() { //user interface interactions and updates on screen mHandler.postDelayed(mTicker, 1000); mTicker.run(); }
Answer
try this change
mTicker = new Runnable() { public void run() { //user interface interactions and updates on screen mHandler.postDelayed(mTicker, 1000); } }; mTicker.run();
We are here to answer your question about Runnable Handler not executing inside fragment. Could not start a runnable - If you find the proper solution, please don't forgot to share this with your team members.