Android pre`loading Activity -
i have question regarding loading of first activity in app. before loading it, app shows screen: https://www.dropbox.com/s/r33n3u3xfmth345/screenshot_2013-08-16-12-02-08.png , , like, load directly activity.
i'll mention im using sherlockactivity, , tried setting theme both in manifest or programatically in oncreate() of activity, same result (pre-load
s screen 2-3 secs, loads activity). thoughts ?
you have use splash screen activity , after have start own activity splash screen activity.
here code splashactivity.
public class splashactivity extends activity { private int splashtime = 3000; private thread thread; private progressbar mspinner; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.activity_splash); mspinner = (progressbar) findviewbyid(r.id.splash_progressbar); mspinner.setindeterminate(true); thread = new thread(runable); thread.start(); } public runnable runable = new runnable() { public void run() { try { thread.sleep(splashtime); } catch (interruptedexception e) { e.printstacktrace(); } try { startactivity(new intent(splashactivity.this,youractivityname.class)); finish(); } catch (exception e) { // todo: handle exception } } }; }
here code activity_spalsh.xml file .....
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#48ad83" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:layout_marginbottom="20dp" android:layout_margintop="10dp" android:gravity="center_horizontal" android:text=" app name " android:textappearance="?android:attr/textappearancelarge" android:textcolor="#a52a2a" /> <progressbar android:id="@+id/splash_progressbar" style="?android:attr/progressbarstylelarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textview1" android:layout_centerinparent="true" android:layout_margintop="5dp" /> </relativelayout>
Comments
Post a Comment