xml - Android: switching from one layout activity to another -


i trying display splash screen 3 seconds , go main screen, both of them being in same class. however, problem that, when try calling new layout.activity, before original layout.acitity class im in, program crash. why?

here little example of talkin about:

 @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_splash);//new activity      displaysplash();      setcontentview(r.layout.activity_visualizer);//original activity  

the way can run if comment out splash activity completely, need it! wont work if comment out other layout activity...

here 2 activities if helps:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#000000" tools:context="comp380.musicvisualizer.visualizer" >  <listview     android:id="@+id/song_list"     android:layout_width="fill_parent"     android:layout_height="wrap_content" > </listview> 

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" tools:context="comp380.musicvisualizer.visualizer" >  <imageview     android:id="@+id/splashscreen"     android:layout_width="wrap_content"     android:layout_height="fill_parent"     android:src="@drawable/logo"     android:layout_gravity="center"/> 

i'd tempted have both fragments , switch between them. if don't want have both views in same layout , change visibility after 3 seconds. view be:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" tools:context="comp380.musicvisualizer.visualizer" >  <imageview     android:id="@+id/splashscreen"     android:layout_width="wrap_content"     android:layout_height="fill_parent"     android:src="@drawable/logo"     android:layout_gravity="center"/>  <listview     android:id="@+id/song_list"     android:layout_width="fill_parent"     android:layout_height="wrap_content"      android:visibility="gone" > </listview> 

and in activity like:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_layout); //the layout above      displaysplash(); // guess waits 3 seconds      // refs views     imageview splashscreen = (imageview) findviewbyid(r.id.splashscreen);     listview songlist = (listview) findviewbyid(r.id.song_list);      // swap visibility     splashscreen.setvisibility(view.gone);     songlist.setvisibility(view.visible);  } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -