我可以在Onprogressupdate()中创建一个按钮 - Asynctask Android吗? [英] Can I Create A Button Dinamicly In Onprogressupdate()-Asynctask Android ?

查看:102
本文介绍了我可以在Onprogressupdate()中创建一个按钮 - Asynctask Android吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们

我在我的android项目中使用AsyncTask类。

我可以在onProgressUpdate()方法中创建一个新按钮吗?

我可以在这个方法中找到元素,但似乎我不能创建一个新的!

当我想要创建一个新的时,它说:

构造函数Button(MMainActivity.RetriveFeedTask)未定义!



你有什么建议吗?!

hi guys
im using AsyncTask class in my android project .
can i create a new button in onProgressUpdate() method ?!
i can find elements inside of this method but it seems i cant create a new one !
when i want to create a new one it says :
the constructor Button (MMainActivity.RetriveFeedTask) is undefined !

do you have any suggestion ?!

推荐答案

按钮需要 Context 因为它是构造函数参数(可能还有 AttributeSet int ,但那不是这里很重要),但是你传递了一些东西 MMainActivity 我猜测的RetrieveFeedTask不是 Context



尝试通过传递 MMainActivity 创建按钮;

Button takes a Context as it's constructor parameter (and possibly an AttributeSet and an int, but that's not important here), but you're passing something MMainActivityRetrieveFeedTask which I am guessing is not a Context.

Try creating the button by passing in just your MMainActivity;
Button b = new Button(MMainActivity);



希望这有助于


Hope this helps


这篇关于我可以在Onprogressupdate()中创建一个按钮 - Asynctask Android吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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