David Prun
David Prun

Reputation: 8433

Display view defined inside activity

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.

Upvotes: 0

Views: 593

Answers (1)

Cheryl Simon
Cheryl Simon

Reputation: 46844

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.

Upvotes: 1

Related Questions