title: ListView disappears Android Studio
body: <p>First of all, I am a beginner in java :)
  My project is to create a todolist. Everything is finished but here I have a little problem. I searched on the internet but all the solutions I found did not do anything.</p>
  
  <p>My app is divided into 3 fragments: my section "Add task", my section "To Do" and my section "Done".</p>
  
  <p>In "To Do" and "Done" I have 2 respective listviews .
  My problem is that when I go in the "Done" section I have my objects in it, but when I change the section to go back to "Add Task" and then go back to "Done", here is no more nothing .. my listView no longer appears.
  On the other hand concerning the list "To do" no worries!</p>
  
  <p>I really have trouble understanding what's going on .. I leave you some code so you can help me thank you in advance!</p>
  
  <p><a href="https://i.stack.imgur.com/WDvvL.png" rel="nofollow noreferrer">My Done Section</a> -> Click on "Add Task" -> <a href="https://i.stack.imgur.com/Xi7Pt.png" rel="nofollow noreferrer">My add section</a> -> Then Go back to "Done" -> <a href="https://i.stack.imgur.com/Jt6N6.png" rel="nofollow noreferrer">Re- Done Section</a></p>
  
  <p>My DoneController : </p>
  
  <pre><code>public class DoneController extends Fragment {
  
  private static ListView lv;
  private static ArrayAdapter&lt;String&gt; mAdapter;
  private static View rootView;
  public static Handler handler = new Handler();
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      rootView = inflater.inflate(R.layout.done, container, false);
      lv = (ListView) rootView.findViewById(R.id.listview_done);
  
      return rootView;
  }
  
  @Override
  public void onResume() {
      super.onResume();
      handler.post(runnableCode);
  }
  
  public static Runnable runnableCode = new Runnable() {
      @Override
      public void run() {
          addTaskDone();
          handler.postDelayed(this, 1000);
      }
  };
      public static void addTaskDone(/*String txt*/) {
  
      TaskDbHelper mHelper = addTaskController.getHelper();
      ArrayList&lt;String&gt; taskList = new ArrayList&lt;&gt;();
      SQLiteDatabase db = mHelper.getReadableDatabase();
      Cursor cursor = db.query(TaskContract.TaskDone.TABLE_DONE,
              new String[]{TaskContract.TaskDone._ID, TaskContract.TaskDone.COL_TASK_DONE_TITLE},
              null, null, null, null, null);
      while (cursor.moveToNext()) {
          int idx = cursor.getColumnIndex(TaskContract.TaskDone.COL_TASK_DONE_TITLE); taskList.add(cursor.getString(idx));
      }
      if (mAdapter == null) {
         mAdapter = new ArrayAdapter&lt;&gt;(rootView.getContext(), R.layout.done, R.id.task_title2, taskList);
         lv.setAdapter(mAdapter);
      } else {
          mAdapter.clear();
          mAdapter.addAll(taskList);
          mAdapter.notifyDataSetChanged();
      }
  
      cursor.close();
      db.close();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>NB : My ToDoController who does not have a problem with the display : </p>
  
  <pre><code>public class TodoController extends  Fragment {
  
  public static Handler handler = new Handler();
  private static ArrayAdapter&lt;String&gt; mAdapter;
  private static ListView mTaskListView;
  public static View rootView;
  public static Boolean isInit = false;
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      rootView = inflater.inflate(R.layout.todo, container, false);
     mTaskListView = (ListView) rootView.findViewById(R.id.listview_todo);
      rootView.setClickable(true);
  
      return rootView;
  }
  
  @Override
  public void onResume() {
      super.onResume();
      Button bttn_del = (Button) rootView.findViewById(R.id.task_delete);
      Button bttn_edit = (Button) rootView.findViewById(R.id.task_edit);
  
      bttn_edit.setVisibility(rootView.INVISIBLE);
      bttn_del.setVisibility(rootView.INVISIBLE);
  
      handler.post(runnableCode);
  
  
      mTaskListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
              Object o = mTaskListView.getItemAtPosition(i);
          }
      });
  
  }
  
  public static Runnable runnableCode = new Runnable() {
      @Override
      public void run() {
          updateUI();
          handler.postDelayed(this, 1000);
      }
  };
  
  public static void updateUI() {
      TaskDbHelper mHelper = addTaskController.getHelper();
      ArrayList&lt;String&gt; taskList = new ArrayList&lt;&gt;();
      SQLiteDatabase db = mHelper.getReadableDatabase();
  
      Cursor cursor = db.query(TaskContract.TaskEntry.TABLE,
              new String[]{TaskContract.TaskEntry._ID, TaskContract.TaskEntry.COL_TASK_TITLE},
              null, null, null, null, null);
  
      while (cursor.moveToNext()) {
          int idx = cursor.getColumnIndex(TaskContract.TaskEntry.COL_TASK_TITLE);
          taskList.add(cursor.getString(idx));
      }
  
      if (mAdapter == null) {
          mAdapter = new ArrayAdapter&lt;&gt;(rootView.getContext(), R.layout.todo, R.id.task_title, taskList);
  
          mTaskListView.setAdapter(mAdapter);
      } else {
          mAdapter.clear();
          mAdapter.addAll(taskList);
          mAdapter.notifyDataSetChanged();
      }
  
      cursor.close();
      db.close();
  }
  </code></pre>