I am using WebView in an ActivityGroup and it will throw an exception if WebView show Dialog and complain the activity is not valid. But it's okay if I set the context of the WebView to the TOP activity. So I wish to know how to set the context in the layout xml ?
                
                A: 
                
                
              So I wish to know how to set the context in the layout xml ?
That's not possible. Though, I have some experience with ActivityGroup, so I know how to solve this problem:
// in your ActivityGroup...
public class YourActivityGroup extends ActivityGroup{
    public static YourActivityGroup self;
    public YourActivityGroup(){
        self = this;
        // the rest of your code here
    }
}
Then, when you need a context in order to show a dialog or a Toast or whatever, you use YourActivityGroup.self.
                  Cristian
                   2010-09-14 05:02:40
                
              But if I get my Spinner with findViewById(...), I can't set the context - how can I achieve that? In combination with ActivityGroup, the spinner doesn't work, unfortunately...
                  swalkner
                   2010-10-06 13:01:39
                I don't know why you would want to set the context to the spinner... is it giving you problems?
                  Cristian
                   2010-10-06 13:51:31
                yes - it asks me if my activity is running: "Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44ed8338 is not valid; is your activity running?"
                  swalkner
                   2010-10-06 17:43:50
                
                
                A: 
                
                
              
            You can use layoutinflater to achieve this:
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.yourLayoutName, null);
this.theSpinner = (Spinner) viewToLoad.findViewById(R.id.Spinny);
this.setContentView(viewToLoad );
Hope that helps. for dialog you can just change context from this to
this.getParent()
                  gunagunaistrimuda
                   2010-10-19 06:52:22