What should i write in parameter of a method in android
This question already has an answer here:
If you are using your method in any activity or service, then no need to pass context,because they have their own context. Just use this
(context) wherever you need. so your code will look like:
void showhistory()
{
TextView historyword[] = new TextView[rs.getColumnCount()];
for(int i=0;i<rs.getColumnCout();i++)
historyword[i] = new TextView(this);
}
创建TextView
需要使用Context
作为上下文
void showhistory(Context context)
{
TextView historyword[] = new TextView[rs.getColumnCount()];
for(int i=0;i<rs.getColumnCout();i++)
historyword[i] = new TextView(context);
}
链接地址: http://www.djcxy.com/p/91374.html
上一篇: 所有关于上下文:如何使用上下文?