Is there a way to add a View dynamically on top of the current Activity’s view? One thing to note is this needs to be done from another class which only has access to the Activity’s context.
ex:
public class ActivityClass extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
…
PopupClass popup = new PopupClass(this);
popup.showPopup();
}
}
public class PopupClass
{
Context context;
void Popup(Context ctx)
{
context = ctx;
}
void showPopup()
{
// Add a view on top of the current Activity.
}
}
Is there a way for PopupClass to be able to add a view to the current Activity with just knowing the context?
PopupClass does not know anything else about the Activity nor can it pass back the View to ActivityClass for ActivityClass to add.
I use custom Dialog’s for this.
http://www.androidpeople.com/android-custom-dialog-example
http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application