java - How do I show a splash screen in Android? -


i want show splash screen when app loads up, java code:

imageview splash = (imageview) this.findviewbyid(r.id.splashscreen);  splash.postdelayed(new runnable(){     splash.setvisibility(view.gone); }, 3000); 

but getting error "cannot resolve symbol" on postdelayed() call. "unexpected token" for

}, 3000); 

finally, layout:

<textview     android:text="@string/hello_world"     android:layout_width="wrap_content"     android:layout_height="wrap_content" />  <imageview     android:id="@+id/splashscreen"     android:layout_width="wrap_content"     android:layout_height="fill_parent"     android:src="@drawable/splash"     android:layout_gravity="center"/>  

logcat:

9:41:01 pm throwable        read access allowed event dispatch thread or inside read-action (see com.intellij.openapi.application.application.runreadaction())        details: current thread: thread[applicationimpl pooled thread 239,4,main] 359404630        our dispatch thread:thread[awt-eventqueue-0 0.4.2#ai-133.970939, eap:true,6,main] 1198871553        systemeventqueuethread: thread[awt-eventqueue-0 0.4.2#ai-133.970939, eap:true,6,main] 1198871553 

9:41:13 pm compilation completed in 12 sec

the manifest file:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.conversation" >  <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.example.conversation.splash"         android:configchanges="orientation|keyboardhidden|screensize"         android:theme="@android:style/theme.notitlebar" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> 

you can follows:

private static final int splash_time_out = 2000; private static final handler mhandler = new handler();  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_splash);      mhandler.postdelayed(new runnable() {          @override         public void run() {                  startactivity(new intent(getapplicationcontext(), youractivity.class));                  finish();            }     }, splash_time_out);     } 

here activity_splash.xml splash activity layout , youractivity activity you're going next.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -