Can’t scroll down on list after runnable is added

  android-studio, runnable

I am having a problem with my list view as after I added a runnable I am not able to scroll down, as every time I try to scroll down it keep on bringing me back up to the top of the page. Below is the code I used in the fragment class

public class DeleteFragment extends Fragment {

    private ListView listViewCrime;
    DatabaseHelper DB_CRIME;
    private ListAdapterDelete adapter;
    private Handler handler;
    private Runnable runnable;

    private DeleteViewModel deleteViewModel;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        deleteViewModel =
                new ViewModelProvider(this).get(DeleteViewModel.class);
        View root = inflater.inflate(R.layout.fragment_delete, container, false);

        listViewCrime = root.findViewById(;

        handler = new Handler();
        runnable = new Runnable() {
            public void run() {
                handler.postDelayed(this, 1000);
                try {
                } catch (Exception e) {
        handler.postDelayed(runnable, 1 * 1000);

        final TextView textView = root.findViewById(;
        deleteViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            public void onChanged(@Nullable String s) {

        return root;


    private void loadData() {
        DB_CRIME = new DatabaseHelper(getActivity());
        List<CrimesDelete> crime = DB_CRIME.getCrimesDelete();
        adapter = new ListAdapterDelete(getActivity(), crime);
        if (crime != null) {


Source: Android Studio Questions