Java 如何在recyclerView中显示StringRequest中的所有数据

Java 如何在recyclerView中显示StringRequest中的所有数据,java,json,android-studio,android-recyclerview,Java,Json,Android Studio,Android Recyclerview,我正在尝试在我的recyclerView中显示数据,但没有图像、字符串和一个int: public class MainActivity extends AppCompatActivity { DataAdapter adapter; RecyclerView rv; TextView txt; List<DataModel> dataList; ArrayList<DataModel> data = new ArrayList<>(); String UR

我正在尝试在我的recyclerView中显示数据,但没有图像、字符串和一个int:

public class MainActivity extends AppCompatActivity {

DataAdapter adapter;
RecyclerView rv;
TextView txt;
List<DataModel> dataList;
ArrayList<DataModel> data = new ArrayList<>();
String URL = "https://run.mocky.io/v3/";
String TAG = "tag: ";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    rv = findViewById(R.id.rv);
    adapter= new DataAdapter(this,data);
    rv.setLayoutManager(new GridLayoutManager(this,2));
    rv.setAdapter(adapter);
    GetData("https://testbankapi.firebaseio.com/products.json");
    //https://run.mocky.io/v3/0773c16f-3c8c-4f96-beee-e8b13f671fd4
}
private void GetData(String url) {
    StringRequest request = new StringRequest(
            Request.Method.GET,
            url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {

                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("-Lh7-wuYbP7AwpipuxNx");

                        for (int i =0;i< jsonArray.length();i++){
                            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                            data.add(
                                    new DataModel(
                                            jsonObject1.getString("category"),
                                            jsonObject1.getString("description"),
                                            jsonObject1.getString("initdate"),
                                            jsonObject1.getString("identification"),
                                            jsonObject1.getString("productname"),
                                            jsonObject1.getInt("value")
                                    )
                            );

                        }
                        adapter.notifyDataSetChanged();

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d("TAG: ",error.getMessage());
                }
            }
    );
    Volley.newRequestQueue(this).add(request);


}
public类MainActivity扩展了AppCompatActivity{
数据适配器;
回收视图rv;
文本视图;
列表数据列表;
ArrayList数据=新的ArrayList();
字符串URL=”https://run.mocky.io/v3/";
String TAG=“TAG:”;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rv=findViewById(R.id.rv);
适配器=新数据适配器(此,数据);
rv.setLayoutManager(新GridLayoutManager(本,2));
rv.设置适配器(适配器);
获取数据(“https://testbankapi.firebaseio.com/products.json");
//https://run.mocky.io/v3/0773c16f-3c8c-4f96-beee-e8b13f671fd4
}
私有void GetData(字符串url){
StringRequest=新StringRequest(
Request.Method.GET,
网址,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
试一试{
JSONObject JSONObject=新JSONObject(响应);
JSONArray JSONArray=jsonObject.getJSONArray(“-Lh7-wuYbP7AwpipuxNx”);
for(int i=0;i
但是只获得了3个项目,我需要显示所有数据,但是,我只知道通过id获取,例如:“-Lh7-wuYbP7AwpipuxNx”,并且需要添加方法post、get、delete、put、patch

拥有ApiCall类、MyAdapter和DataModel我不明白为什么要获取这些元素: