hi all; am porting a framework that works on J2SE and blackberry. this framework "dynamically" creates screens (xlate as views w/layout managers in Android). the main entry point to the framework is to create an instance of thread (for example, Main.java that extends Thread) and starts it. on starting, the framework uses some data files for the construction of the platform specific widgets.
in the Android world, i'm struggling with the idea or notion of 1view = 1activity. so here is what i've done: a) created an activity which shows a basic button to start and stop this framework. on clicking start, i instantiate a subclass of AsyncTask. b) altered the framework so that Main.java does *NOT* inherit from Thread. c) this subclass of asynctask doInBackground() creates the instance of Main and simply invoke its run() method (NOTE: again Main is not a thread so it'll run in the AsyncTask worker thread). d) also w/in the framework, i dynamically instantiate android widgets - Button, and EditText only for current test case. these are placed on a LinearLayout "panel". all these happen in different framework subclasses. e) when the framework decides to "push" a screen (i.e., view), i populate the LinearLayout with the necessary widgets and then delegate to the subclass of AsyncTask where i simply invoke publishProgress() with the root viewgroup (in this case an instance of LinearLayout). f) Then in the AsyncTask subclass, w/in onProgressUpdate(), i push the current view by calling activity.setContentView (i hold onto a reference of activity in the async task subclass) two things happen: 1) either nothing shows up on the emulator screen, or 2) i get a ViewRoot$CalledFromWrongThreadException - which is *weird* 'cause i'm using AsyncTask. Questions: a) presuming that dynamically created "panel" has something wrong w/it and that is why its not rendered. i've checked the values of the view being supplied to setContentiView and it has the two widgets (Button and EditText) with appropriate text values for labels etc. a1) what else can i check ? a2) are there reasons why an activity would not update its contentView if the view is supplied by the worker thread in AsyncTask ? a3) am using the debugger and have android src code configured (albeit the line #'s are out of sync) - so/but i can't figure out where its failing to update and use the new view. any help? b) why would i get VIewRootCalledFromWrongThreadException even when using the AsyncTask?? c) general architecture... can one create Activity classes dynamically w/o having their descriptions in xml file ? Reason why i ask is, perhaps for the android platform, the best way to port this framework is to implement "subactivities" -- however these subactivities are not know a priori, so i must be able to create them dynamically. appreciate help. kindest regards, S- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

