title: Listview doesn't appear at Fragment after second compile
body: <p>Listview doesn't appear at Fragment after second compile.
  The button at fragment works, so the problem is with listview and adapter, but I can't understand where the problem is.</p>
  
  <p>Even if I delete the program and reinstall, it doesn't help. Only if move some other place method <code>updatepost</code> it can work once. 
  Hope for advice! I'm just learning all this.</p>
  
  <h3>Main fragment:</h3>
  
  <pre><code>public class MainFragment extends Fragment {
  
  ArrayList&lt;Bitmap&gt; bitArray;
  CustomListAdapter adapter;
  
  public MainFragment() {
  }
  
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
  }
  
  @Override
  public void onStart() {
      super.onStart();}
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_main, container, false);
      ListView listview = (ListView)rootView.findViewById(R.id.listViewPost);
      Log.v("Plaxehere","1");
          adapter = new CustomListAdapter(getContext(), bitArray);
          listview.setAdapter(adapter);
  
          listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long l) {
                  Toast.makeText(getActivity(), "YESS", Toast.LENGTH_SHORT).show();
              }
          });
  
  
      Button but =(Button) rootView.findViewById(R.id.button_back_to_home);
      but.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              Toast.makeText(getContext(), "Text", Toast.LENGTH_SHORT).show();
              /*Intent intent = new Intent(getActivity(), MainActivity.class).putExtra(Intent.EXTRA_TEXT, "Hello");
              startActivity(intent);*/
          }
      });
  
      return rootView;
  }
  
  
  private void updatePost() {
  
      FetchPosterTask postTask = new FetchPosterTask(getActivity());
      postTask.execute("uk_news.json");
  
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      bitArray = new ArrayList&lt;&gt;();
      updatePost();
  
  }
  
  class FetchPosterTask extends AsyncTask&lt;String, Void, ArrayList&lt;Bitmap&gt;&gt; {
      private final String LOG_TAG = FetchPosterTask.class.getSimpleName();
      private Context context;
  
  
      public FetchPosterTask (Context myContext) {
          this.context = myContext;
      }
  
      @Override
      protected ArrayList&lt;Bitmap&gt; doInBackground(String... params) {
  
          if(params.length ==0 ){
              return null;
          }
  
          String json = null;
  
          try {
              json = getJson(params[0]);
  
          } catch (IOException e)
          {
              e.printStackTrace();
          }
  
          try {
              String[] masPst = getPosterfromJsonAsString(json);
              ArrayList&lt;Bitmap&gt; result =decodeImageToBitmap(masPst);
  
              return result;
          }catch (JSONException e){
              Log.e(LOG_TAG, "Place 5", e);
          }
  
          return null;
      }
  
      private String getJson(String filename) throws IOException{
          InputStream is = this.context.getAssets().open(filename);
          int size = is.available();
          byte[] buffer = new byte[size];
          is.read(buffer);
          is.close();
          return new String(buffer);
  
      }
  
      private String[] getPosterfromJsonAsString(String posterJson) throws JSONException {
          final String OWM_NFO = "nfo";
          final String OWM_NWS = "nws";
          final String OWM_PST = "pst";
  
  
          JSONObject imageJson = new JSONObject(posterJson);
          JSONObject nfoArray = imageJson.getJSONObject(OWM_NFO);
          JSONArray nwsArray = nfoArray.getJSONArray(OWM_NWS);
  
          String[] resultStr = new String[nwsArray.length()];
  
          for(int i =0; i&lt;nwsArray.length(); i++){
              JSONObject pst = nwsArray.getJSONObject(i);
              String im = pst.getString(OWM_PST);
  
              resultStr[i] = im;
          }
  
          return resultStr;
  
      }
  
  
      public ArrayList&lt;Bitmap&gt; decodeImageToBitmap (String[] base64Image) {
          ArrayList&lt;Bitmap&gt; bitmapArrayList = new ArrayList&lt;Bitmap&gt;();
          for(int i =0; i&lt;4; i++) {
              byte[] decodedString = Base64.decode(base64Image[i], Base64.DEFAULT);
              Bitmap base64Bitmap = BitmapFactory.decodeByteArray(decodedString, 0,
                      decodedString.length);
              bitmapArrayList.add(i, base64Bitmap);
          }
          return bitmapArrayList;
      }
  
      @Override
      protected void onPostExecute(ArrayList&lt;Bitmap&gt; bitmapArrayList) {
          if(bitArray.size()!=0){
              bitArray.clear();
              bitArray.addAll(bitmapArrayList);
          }
          else{
                  bitArray.addAll(bitmapArrayList);
  
          }
      }
  }
  
  
  }
  </code></pre>
  
  <h2>Adapter</h2>
  
  <pre><code>public class CustomListAdapter extends BaseAdapter {
  private final String LOG_TAG = CustomListAdapter.class.getSimpleName();
  private ArrayList&lt;Bitmap&gt; bitmapArrayList;
  private LayoutInflater layoutInflater;
  
  public CustomListAdapter(Context context, ArrayList&lt;Bitmap&gt; bitmapArrayList) {
      this.bitmapArrayList = bitmapArrayList;
      this.layoutInflater = LayoutInflater.from(context);
  }
  
  @Override
  public int getCount() {
      return bitmapArrayList.size();
  }
  
  @Override
  public Object getItem(int position) {
      return bitmapArrayList.get(position);
  }
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
  
      if(convertView == null) {
          convertView = layoutInflater.inflate(R.layout.list_post_item, null);
  
          holder = new ViewHolder();
          holder.imageView = (ImageView) convertView.findViewById(R.id.list_item);
          convertView.setTag(holder);
          Log.v(LOG_TAG,"1");
      }
   else {
      holder = (ViewHolder) convertView.getTag();
          Log.v(LOG_TAG,"2");
  }
      Log.v(LOG_TAG,"3");
      if(getItem(position) == null) {
          holder.imageView.setImageResource(R.drawable.pst_0);
          Log.v(LOG_TAG,"5");
      }
      else{
          holder.imageView.setImageBitmap((Bitmap) getItem(position));
          Log.v(LOG_TAG,"6");
      }
      Log.v(LOG_TAG,"4");
  
      return convertView;
  }
  
  static class ViewHolder {
      ImageView imageView;
  
  }
  
  
  }
  </code></pre>
  
  <h2>Main Activity</h2>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new MainFragment())
                  .commit();
      }
  
  }
  
  }
  </code></pre>