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 pul开发者_如何学Goses
}
}
}
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.
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.
精彩评论