如何调用的onClick(视图v)明确法在Android?可能吗?视图、明确、onClick、Android

2023-09-12 06:03:44 作者:雨后星辰

我想从我的活动的方法调用其它类的的onClick(视图v) 的onCreate()。可能吗?

I want to call an onClick(View v) of other class from my activity's method onCreate(). Is it possible?

由于我有一个Popupwindow在其他类的一个onClick方法,所以当一个方向的变化,我希望我的横向模式的popupwindow是完整的,并在运行时出现。怎样才能做到呢?

Because I have a Popupwindow in an onClick method of other class, so when an orientation changes, I want my landscape mode's popupwindow to be intact and appear at runtime. How can it be done?

在此先感谢!

推荐答案

假设你要调用的onClick()是一个视图的 X 的,使用x.performClick()或x。 callOnClick()。检查他们的开发者指南中的javadoc了解更多详情。

Assuming that the onClick() you want to call is for a View x, use either x.performClick() or x.callOnClick(). Check their javadoc in the Developers Guide for more details.

请注意,你必须有一个手柄为x。如果你的方向变动,你应该销毁的PopupWindow并重新显示出来,它应该工作。

Notice that you have to have a handle to x. If your orientation changes, you should destroy the PopupWindow and re-display it, which should work.