为什么我的Android Adapter没有getActivity()方法?然而,许多教程都可以访问内部的getActivity()方法,让我们说一下recyclerview适配器
我已经尝试使用构造函数从片段传递getActivity()但仍然没有完成我想要的.
My Fragment调用适配器
package layout;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import com.example.elm.login.Navigation;
import com.example.elm.login.R;
import com.example.elm.login.adapter.NotesAdapter;
import com.example.elm.login.model.Note;
import com.example.elm.login.services.note.UploadNote;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link NotesFragment.OnFragmentInteractionListener} interface
* …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 django 应用程序连接到我的 mysql 数据库。我在迁移过程中收到以下错误:
django.core.exceptions.ImproperlyConfigured:加载 MySQLdb 模块时出错。你安装了mysqlclient吗?
我已经安装了 mysqlclient 如下:
需求已经满足:mysqlclient in /usr/local/lib/python3.7/site-packages (1.4.2.post1)
我也尝试过使用 pymysql 并将以下代码添加到ini .py 文件中:
import pymysql
pymysql.install_as_MySQLdb()
Run Code Online (Sandbox Code Playgroud)
给我一些其他错误。可能有什么问题?
Python 3.7 、 mysql 5.7 和 Django 2.2 是我的安装版本。