I'm getting error with this code. Why huhu 123123123
Thread timer = new Thread()
{
public void run()
{
try
{
sleep(1500);
splash.setImgeResource(R.drawable.dilclogo);
sleep(1500);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally
{
Intent intent = new Intent(MainActivity.this, MenuScreen.class);
startActivity(intent);
}
}
};
timer.start();
You should update ui on the ui thread. Use runonUithread.
But i would suggest you to use a handler.
splash.xml
Using handlers and postdelayed
splash.xml
Perhaps consider using
This is because you can NOT access your UI/Main thread directly from any other thread. You can use below methods to access your UI thread though:
AsyncTask
runOnUiThread()
You can also read this article on threading in android to help you understand this concept better.
You can not use normal threading on android system. Give you some example on thread on android :D
---> Android Asynctask
Android Developer - Android Asynctask
You can use this for some loading effect on UI in android.
---> runOnUiThread
In your case, I suggest to use this. You can have more detail here.
Click for detail
USEAGE::
put splash.setImgeResource(R.drawable.dilclogo); line into runOnUiThread .