我是靠谱客的博主 明亮钢笔,这篇文章主要介绍android Toast报错 Activity context.this cannot be resolved to a variable,现在分享给大家,希望可以做个参考。
处理方法
你过你继承了Activity,就使用下面的2个方式
Toast.makeText(ClassName.this, "Couldn't launch the market",Toast.LENGTH_LONG).show();
或者
Toast.makeText(getApplicationContext(), "Couldn't launch the market",Toast.LENGTH_LONG).show();
如果你的类继承了 Fragment ,就使用下面的方式
Toast.makeText(getActivity(), "Couldn't launch market",Toast.LENGTH_LONG).show();
原文地址:http://www.itmmd.com/201411/153.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
最后
以上就是明亮钢笔最近收集整理的关于android Toast报错 Activity context.this cannot be resolved to a variable的全部内容,更多相关android内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复