I have a problem with ListView, I need the checkboxes to go first on the layout, and then the list, the checkbox clicks filter the list.
layout.xml
<?xml version="1.0" encoding="utf-8"?> <CheckBox android:id="@+id/prop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Пропущенные"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/prop" android:background="@drawable/frame" > <!-- the icon view --> <ImageView android:id="@+id/tvIcon" android:layout_width="160dp" android:layout_height="90dp" android:padding="5dp" android:scaleType="fitXY" android:layout_alignParentLeft="true" /> <!-- the container view for the title and description --> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/tvIcon" android:layout_centerVertical="true" > <!-- the title view --> <TextView android:id="@+id/tvTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@android:style/TextAppearance.Medium" /> <!-- the timer view --> <Chronometer android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tvChronometer" android:layout_below="@id/tvTitle" android:textAppearance="@android:style/TextAppearance.Medium" /> </RelativeLayout> </RelativeLayout> ArchiveFragment.class
public class ArchiveFragment extends ListFragment { private List<ListViewItem> mItems; // ListView items list @Override public void onAttach(Activity activity) { super.onAttach(activity); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new DealsTask().execute((Void) null); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Удаляем разделители из ListView в ListFragment getListView().setDivider(null); } @Override public void onListItemClick(ListView l, View v, int position, long id) { // Получаем объект theListView ListViewItem item = mItems.get(position); String[] strArr = item.title.split("/"); // Делаем что-нибудь. Fragment fragment = null; Class fragmentClass = DetailFragment.class; try { fragment = (Fragment) fragmentClass.newInstance(); } catch (Exception e) { e.printStackTrace(); } Bundle bundle = new Bundle(); bundle.putString("suggestion_id", strArr[1]); bundle.putString("listActivity", "1"); assert fragment != null; fragment.setArguments(bundle); android.app.FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit(); ConstantsAPP.active_item = ConstantsAPP.ACTIVE_ORDER_DETAIL; } public class DealsTask extends AsyncTask<Void, Void, String> { @Override protected String doInBackground(Void... params) { return new APIweb(getActivity(), false).GetArchiveAll(); } @Override protected void onPostExecute(String strJson) { super.onPostExecute(strJson); if(strJson != null) { JSONObject dataJsonObj; String suggestion_aссepted = null; try { dataJsonObj = new JSONObject(strJson); JSONArray js_arr = dataJsonObj.getJSONArray("result"); JSONObject error = js_arr.getJSONObject(0); if (parseInt(error.getString("error")) == 0) { // initialize the items list mItems = new ArrayList<ListViewItem>(); JSONArray js_arr_suggestion = dataJsonObj.getJSONArray("suggestion"); for (int i = 0; i < js_arr_suggestion.length(); i++) { JSONObject obj_suggestion = js_arr_suggestion.getJSONObject(i); String suggestion_id = obj_suggestion.getString("suggestion_id"); suggestion_aссepted = obj_suggestion.getString("suggestion_aссepted"); String d_id = obj_suggestion.getString("d_id"); String d_type = obj_suggestion.getString("d_type"); String d_created_at = obj_suggestion.getString("d_created_at"); Drawable img = getResources().getDrawable(R.drawable.defaultwork); mItems.add(new ListViewItem(img, d_id + "/" + suggestion_id + "/" + d_type, d_created_at, null, null, null, suggestion_aсcepted)); } // initialize and set the list adapter setListAdapter(new ListViewAdapter(getActivity(), mItems, R.layout.fragment_archive_listview)); } else if(parseInt(error.getString("error")) == 1) { setEmptyText("Нет активных заявок."); mItems = new ArrayList<ListViewItem>(); setListAdapter(new ListViewAdapter(getActivity(), mItems, R.layout.fragment_archive_listview)); } } catch (JSONException e) { e.printStackTrace(); } } } } }

CheckBoxasHeader- Vladyslav Matviienko