如何从没有扩展Activity类的类更新的TextView [英] How to update TextView from a class that doesn't extend Activity class

查看:109
本文介绍了如何从没有扩展Activity类的类更新的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid。我有一个艰难的时间与我的code。
这里是我的问题。
我在我的MainActivity一个TextView延伸活动。而这个TextView的顶部已经从它扩展适配器类并实现GestureDetector另一个类更新。

I am New to Android. I am having a tough time with my code. Here is my problem. I have a TextView in my MainActivity which extends activity. And this textview has top be updated from another class which extends an Adapter class and implements GestureDetector.

根据一扔事件我更新我的TextView。我怎样才能做到这一点。

Based on the fling event I am updating my textview. How can i achieve this.

推荐答案

我已经解决了我的问题atlast。我加的方法present以下线在我的其他类。所以,现在当方法被调用时,我的TextView自动改变其文本。

I have solved my problem atlast. I added the below line in the method present in my other class. So now when the method is called, my textView changes its text automatically.

mymainActivity.textView_name.setText((new myCurrentclass_Name(this.context_name)).some_array[value]);

这是我被允许改变我的TextView的,我在我的MainActivity的文本。

This is how I was allowed to change the text of my TextView which I had in my MainActivity.

这篇关于如何从没有扩展Activity类的类更新的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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