tags:

views:

26

answers:

1

I have an activity 'A' which is called from Main activity every second until timer ends.

A is called to draw pulses until timer ends

public class A extends Activity
{    
*some code*    

   public class NestedView extends View   
   {   
         public void onDraw(Canvas canvas) 
         {

              * draw pulses
         }         
    }    
}

I want to display the "pulses view" in main.xml which already has some buttons and scrollers, text boxes etc. How can I reserve a portion of screen for this pulses to be displayed. I cannot redo the xml file because the above pulses are dynamic and the image has a red line traversing across x axis for user defined time.

+1  A: 

You can't have both "A" activity and Main activity visible at the same time.

Instead, create a new View and add it to the layout in main.xml. See 2D graphics documentation for an example. It sounds like the section titled Shape Drawable might meet your needs.

edit: You can access the view from within your activity by calling (MyView)findViewById(R.id.my_view) From there, you should be able to configure your view with shared preferences, etc.

Also, this article on updating the ui on timer might be useful.

Mayra
see edits for more details.
Mayra
http://stackoverflow.com/questions/3357769/unable-to-use-shared-preference-within-class-extends-view
http://stackoverflow.com/questions/3365384/embed-dynamic-view-in-main-xml
http://stackoverflow.com/questions/3416866/android-draw-view-on-image