如何在非UI方法中使用UI函数? [英] How to use UI functions in non UI methods?

查看:87
本文介绍了如何在非UI方法中使用UI函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个具有实用程序功能的类.

I want create a own class with utility functions.

因此,我想使用典型的Activity函数并围绕它们构建一些东西.

Therefore i want to use typical Activity-functions and build something around them.

我想使用setTitle函数例如:

I want use the setTitle function for example:

       public void frameworkSetTitle() {
            String testValue;
            setTitle(testValue);
       }

是否可以在自己的类中使用此函数并将结果传递回调用方Activity?

Is it possible to use this functions in own classes and pass the result back to the calling Activity?

推荐答案

您必须将Activity实例传递给util方法,并在其中调用所需的方法,例如setTtitle.

You have to pass the Activity instance to the util method and call the desired methods there, like setTtitle.

这篇关于如何在非UI方法中使用UI函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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