我可以在Onprogressupdate()中创建一个按钮 - Asynctask Android吗? [英] Can I Create A Button Dinamicly In Onprogressupdate()-Asynctask Android ?
本文介绍了我可以在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 aContext
as it's constructor parameter (and possibly anAttributeSet
and anint
, but that's not important here), but you're passing somethingMMainActivity
RetrieveFeedTask which I am guessing is not aContext
.
Try creating the button by passing in just yourMMainActivity
;
Button b = new Button(MMainActivity);
希望这有助于
Hope this helps
这篇关于我可以在Onprogressupdate()中创建一个按钮 - Asynctask Android吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文