java - starting a new activity in onCreate works only with delay -


i have simple activity shows 2 buttons, , load activity 1 finished loading.

@override public void oncreate(bundle savedinstancestate) {     dbg("starting on create");     super.oncreate(savedinstancestate);      dbg("stting content view");     setcontentview(r.layout.main);      createdrpopup();  }  private void createdrpopup(){     dbg( "created new activity");     startactivityforresult(new intent(this, drpopup.class),                             dr_popup_activity_id); } 

i don't errors code, new activity doesn't load properly. way blanc screen.

but if call new activity delay, works fine.

@override public void oncreate(bundle savedinstancestate) {     dbg("starting on create");     super.oncreate(savedinstancestate);      dbg("stting content view");     setcontentview(r.layout.main);      thread splashtread = new thread() {         @override         public void run() {             try {                 sleep(500);             } catch(interruptedexception e) {             } {                 createdrpopup();             }         }     };     splashtread.start(); }  private void createdrpopup(){     dbg( "created new activity");     startactivityforresult(new intent(this, drpopup.class),                             dr_popup_activity_id); } 

my question this:

is there better way wait activity finish loading. can't sure 500ms enough each time.

thank suggestions.

requested code dr_popup (this simple gets)

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      dbg("created new activity");      setcontentview(r.layout.dr_webview);     dbg("web view created");  } 

and both layouts

main

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"       android:layout_width="wrap_content"         android:layout_height="wrap_content">     <button android:text="button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></button>     <spinner android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="wrap_content" android:id="@+id/spinner1"></spinner> </linearlayout> 

popup

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dr_popup_webview_layout" android:layout_width="fill_parent" android:layout_height="fill_parent"  android:orientation="vertical">     <webview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dr_popup_webview" android:layout_width="fill_parent"  android:layout_height="100dip"/>     <linearlayout  android:id="@+id/framelayout1" android:layout_height="100dip" android:layout_width="fill_parent" android:orientation="horizontal">         <edittext android:id="@+id/dr_submit_text"          android:layout_height="wrap_content"            android:layout_width="wrap_content"         android:layout_weight="4">             <requestfocus></requestfocus>         </edittext>         <button             android:text="button"           android:id="@+id/dr_submit_button"          android:layout_height="wrap_content" android:layout_width="wrap_content"    android:layout_weight="1"></button>     </linearlayout> </linearlayout> 

edit: problem seems caused manifest line @android:style/theme.dialog

    <activity android:theme="@android:style/theme.dialog"               android:name=".drpopup"               android:label="@string/dr_popup">     </activity> 

if remove that, things seem work, solution work line.

and picture shows problem. http://i.imgur.com/zocyw.png

i don't see reason provided code why have insert 500 ms delay… that's non-sense insert delay. clarifications needed: 1. did heavy processing within original activity? 2. startactivityforresult called purpose (since code fragments doesn't show onactivityresult implementation)?

i try implement minimal example , update post asap…

−− update

after several attempts understand , fix issue parallel chat session, reproduced problem on fresh 1.5 emulator. problem finaly comes use of android:theme="@android:style/theme.dialog" callee activity. issue observed on android 1.5 (both device , emulator). whatever declared in second layout, whenever associated activity started, nothing displayed. display blank , push on button initiates transient display of activity go first activity (later part nominal). not explain why happens , suggest zidarsk8 give popupwindow try or define custom style (trial/error approach based on android theme.dialog source definition).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -