0

I got stuck looking for the method to add a "header" on my recyclerview template. Looks like I need to use "TabLayout" over RecyclerView. But I'm not an expert in Android to see how to do it.

at the moment I have the method to get my array from JSON and drawing it with recyclerview. I used a guide to get it.

private void getGestores(String lgestoresurl) {

   // Toast.makeText(getApplicationContext(), lgestoresurl, Toast.LENGTH_LONG).show();
    StringRequest rq = new StringRequest(Request.Method.GET, lgestoresurl, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try {
                JSONObject jsonObject = new JSONObject(response);
                JSONArray array = jsonObject.getJSONArray("result");
                for (int i = 0; i < array.length(); i++) {
                    JSONObject ob = array.getJSONObject(i);
                    List_Gestores lgest = new List_Gestores(
                            ob.getString("car"),
                            ob.getString("usu"),
                            ob.getString("usu"),
                            ob.getString("Per01"),
                            ob.getString("Per02"),
                            ob.getString("Per03"),
                            ob.getString("Per04"),
                            ob.getString("Prom"));
                    list_gestores.add(lgest);
                }
                rv_lgestores.setAdapter(lgadapter);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(rq);
}

But my layout only shows the list but not a header like datatable.

So that's what I am looking for:
enter image description here

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
G. Romero
  • 47
  • 6
  • You will have to use the viewholder pattern here. Check out this thread https://stackoverflow.com/questions/26530685/is-there-an-addheaderview-equivalent-for-recyclerview – Shubham Oct 23 '19 at 22:13

1 Answers1

0

got it adding textview lol

<TextView <!-- that textview similar to my list and all done -->
    android:id="@+id/tv_names"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:width="85dp"
    android:textSize="15dp"
    android:textStyle="bold"
    android:text="Names: "/>

<android.support.v7.widget.RecyclerView
    android:id="@+id/usu_gestores"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="20dp" />

G. Romero
  • 47
  • 6