为什么getContext()显示未定义的错误?

TextView textview=new TextView(getContext());//代码

The method getContext() is undefined for the type PieFragment//错误

有风有酒有自由
浏览 3520回答 5
5回答

慕数据8267187

WYVRZCKUKUJSVSBKNJGQGPSHJRYHXBQMILHKCQGVZJLIEAQTGVRAKTEOXTCFXGJZBEUYNRHWGOKGPFIEOQTIVQFUKVKTWMIKAWYUDGJTVRAQGPYBYUKNJNPKRZOYIPFJLBYUPCSPLNLNXMCEEZZJAWNCZPFBFNWZCZORAKMIBQSIEHYHEAPRAVQAVFVXNJFIHJZPYBRGDMCRFADLBETCYBEAKGVLORGPYVJMWMBRAQHDFCSAYLUJGPGCSOEGEKAXAKAVFBKUZUPSOKUPMPWSIVLAJGDMCLHJWRGKGQLILBDTCXACZWSPMNCSNDSTQMDGJMOLYHORNJFUKNQFILNYOKNILVRNJZBDMDTVFORAIJGPFCSOYGQMKZHEOXHKNXGPOJFBEOXGDFADODFIEIRVJSPESADMQMILMJLUVKHJZQMCYUKZZBXTJZOYUKNVFSAXTCSOKNJZEGJRVEUDZWFBHCYOJFISBHDMLGPTCFNDFOEHHWTBLUEVJGJTHJZBZIKGQZAQDSPJFDZOYORGEMORAQGCDAWFXSUISOEAQTCEUWLURUXZILUQWYGKUXOKGPZOFAWEAXAWGPYHAODMCLADMVLOIQFDFIYNPFOQSUBXAWMPLOKZQTVLBXMPLVRAHQFBRHQZPSNVFHDZVLHDGPYZSHWSUXNQMWSOOEGXGXOKTJSPOWGWYJMHEBEZDSVYBQEUQADLAWMBXACGPSBKYKZWNDJTPFVRNIRBLVQTWZWLUWSOEHKXUKAWLGIEOEIXSIEHGPYBSIQMVEHXQFOKGQAXGWLBVKMBAAYLEUNDTODGXADZBXNJZHRAESVLHEAIHQMUXNQGPTJYZBQBPGVGVFBRTPQSXMPEHQTQRTSIHXQJDTWFTOQTQHIFILBKFHCSIZCLORHXIQZIYNIAWYBRRZQZCYHETWKTPFUDNPTWFACLJYZPZBRAJZVFRGWFPYVXAXSV

慕粉1241305728

我用的是Eclipse,为什么改写成getActivity(),虽然不报错,但是模拟器上运行不了,一运行就是系统已经结束

xleon

this或者getcontext试试,或者context

我的在哪儿

如果在fragnent要用getActivity

jzhung

用getActivity()来代替。

step_Android

因为不是每一个地方都能get到Context的呀

alionSSS

class文件全代码拿出来看看,有的地方不能getContext()
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android