如何调用的onClick(视图v)明确法在Android?可能吗? [英] How to call onClick(View v) method explicitly in an Android? Is it possible?

查看:101
本文介绍了如何调用的onClick(视图v)明确法在Android?可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的活动的方法调用其它类的的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.

这篇关于如何调用的onClick(视图v)明确法在Android?可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆