开发者

android why is TabActivity with Activity's crashing when open Dialog

I see there are like 10 answers for this question and I have read them all but cannot get this to work.

Im moving my activity's into this TabGroup and I have 3 activity's inside a tabgroup and got help doing it from here: Multiple Android Activities in a TabActivity

When opening a Custom Dialog i get this error:

07-12 10:07:56.985: ERROR/AndroidRuntime(9532): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@462d96f0 is not valid; is your activity running?

I know this error say that Context is bad.

On the ColorPickerView (below) that doesn't work, I'm debugging and can see the Constructor doing it's job but as soon as constructor finish it crashed.

The thing is I have 3 similar errors from the other two activities, one CheckBox, and two Spinner's.

I could easily fix it by changing the Context appropriately .

This on is more complicated and the View stack looks like this:

TabGroup  
.......TabHost (public class FileEditMainActivity extends Activity)    
...............ImageView (public class FileEditImageView extends ImageView )      
........................Dialog (public class ColorPickDialog extends Dialog )  
..............................View (private class ColorPickerView extends View  )

No matter how i change the Context the system tells my that the Context is not alive.

The ColorPickerView is always crashing..

Must say also that this is working if i dont use the TabGroup. When I put the FileEditMainActivit in the TabGr开发者_JAVA技巧oup something goes wrong with the Context.

Anyone have an ide of what to do?


Since everything is inside an ActivityGroup i hade to do like

getparent().getParent()

This might look brutal but it worked and for my level of experience im consider it to be a victory :)

EDIT

the line getparent().getParent() would be the context parameter, eg:

final ProgressDialog dialog = ProgressDialog.show(this.getParent().getParent(), null, "Prcocessing", true, true);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜