相关疑难解决方法(0)

在片段中使用上下文

如何在片段中获取上下文?

我需要用我的数据库其构造函数采用的背景下,但getApplicationContext()FragmentClass.this没有工作,所以我能做些什么?

数据库构造函数

public Database(Context ctx)
{
    this.context = ctx;
    DBHelper = new DatabaseHelper(context);
}
Run Code Online (Sandbox Code Playgroud)

java android android-context android-fragments

645
推荐指数
12
解决办法
46万
查看次数