Created a list, but the lines go behind the screen. When I start flipping header disappears. Screen as it looks: enter image description here

Layout sheet:

<ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/lv__pipes_flowV" android:layout_gravity="center_horizontal" android:headerDividersEnabled="true" android:scrollingCache="false"/> 

Sheet creation code:

 ListView lv__pipes_flowV; // упаковываем данные в понятную для адаптера структуру ArrayList<Map<String, Object>> data = new ArrayList<Map<String, Object>>( diameter_table.length); Map<String, Object> m; for (int i = 0; i < diameter_table.length; i++) { m = new HashMap<String, Object>(); m.put("column_1", diameter_table[i]); m.put("column_2", min_flow_table[i]); m.put("column_3", max_flow_table[i]); data.add(m); } // массив имен атрибутов, из которых будут читаться данные String[] from = { "column_1", "column_2", "column_3" }; // массив ID View-компонентов, в которые будут вставлять данные int[] to = { R.id.tv_table_row_3_column_1, R.id.tv_table_row_3_column_2, R.id.tv_table_row_3_column_3 }; // создаем адаптер SimpleAdapter sAdapter = new SimpleAdapter(getActivity(), data, R.layout.table_row_3_column, from, to); // определяем список и присваиваем ему адаптер lv__pipes_flowV = (ListView) rootView.findViewById(R.id.lv__pipes_flowV); LayoutInflater ltInflater = LayoutInflater.from(getActivity()); View header = ltInflater.inflate(R.layout.table_row_3_column, null, false); TextView tv_table_row_3_column_1 = (TextView) header.findViewById(R.id.tv_table_row_3_column_1); tv_table_row_3_column_1.setText(R.string.tv_pipes_flowD_Diameter); TextView tv_table_row_3_column_2 = (TextView) header.findViewById(R.id.tv_table_row_3_column_2); tv_table_row_3_column_2.setText(R.string.gv_pipes_flowV_header_min_flow_text); TextView tv_table_row_3_column_3 = (TextView) header.findViewById(R.id.tv_table_row_3_column_3); tv_table_row_3_column_3.setText(R.string.gv_pipes_flowV_header_max_flow_text); lv__pipes_flowV.addHeaderView(header); lv__pipes_flowV.setAdapter(sAdapter); 
  • Or maybe you need not header? - Kota1921
  • The header of the table is sort of like a header. Those. not part of the data, but the name .. - Alexander Tymchuk

2 answers 2

There is no way to attach the header ListView and prevent it from scrolling because it is implemented as another list item and scrolls along with the rest.

You need to place the header as a separate markup, not as part of a ListView .

    This is called the Sticky List Header . There are already at least 20 libraries implementing this behavior.
    Here is one of them .
    That's how you can find them all (or most).
    But this application contains demonstrations of many useful libraries, including several of those that you need.