title: android displaying dialogfragment in asynctask
body: <p>I'm having some problems with my dialog fragment in my AsyncTask.  Basically here is the gist of what occurs.  I have a custom list adapter to build a ListView.  On preExecute, I display my dialog.  The data is loaded into the list via doInBackground.  On postExecute, I dismiss my dialog.  Problem is that I am now left with a blank screen.  The dialog comes and then disappears, but no list of items.  Really not sure what is going on.  Here is my DialogFragment class:</p>
  
  <pre><code>public class ProcessingDialog extends DialogFragment {
  
      private String dialog_text;
  
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // Use the Builder class for convenient dialog construction
          final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          // Get the layout inflater
          LayoutInflater inflater = getActivity().getLayoutInflater();
  
          View dialog_view = inflater.inflate(R.layout.dialog_loading, null);
          final TextView tv1 = (TextView) dialog_view.findViewById(R.id.dialog_text);
          dialog_text = getArguments().getString("message");
          tv1.setText(dialog_text);
          // Inflate and set the layout for the dialog
          // Pass null as the parent view because its going in the dialog layout
  
          builder.setView(dialog_view);
  
          // Create the AlertDialog object and return it
          return builder.create();
      }
  }
  </code></pre>
  
  <p>Here is my MainActivity:</p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  
      private Context context = this;
      private List&lt;RandomdataModel&gt; list;
      private LayoutInflater layoutInflater;
      private CustomListAdapter listAdapter;
      private ProcessingDialog dialog_fragment_loading;
      private MessageDialog dialog_fragment_message;
  
      private final String[] parts = new String[]{"Sprocket", "Screw", "Nail",
              "Widget", "Gear", "Cog", "Tube", "Spring", "Tape", "Bolt"};
  
  
      private static final String LOGTAG = "MainActivity";
      private static final boolean DEBUG = true;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.list_view);
  
          listAdapter = new CustomListAdapter(this);
          ListView listView = (ListView) this.findViewById(R.id.listView);
          listView.setAdapter(listAdapter);
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View view, int position, long id) {
                  if (DEBUG) {
                      Log.d(LOGTAG, "onItemClick(): arg0=" + arg0.getClass().getSimpleName());
                      Log.d(LOGTAG, "onItemClick(): arg1=" + view.getClass().getSimpleName());
                  }
  
                  TextView tv1 = (TextView) view.findViewById(R.id.listitemTextIDValue);
                  TextView tv2 = (TextView) view.findViewById(R.id.listitemTextPartValue);
                  RandomdataModel data = new RandomdataModel();
  
                  data.setId(Integer.parseInt(tv1.getText().toString()));
                  data.setPart(tv2.getText().toString());
  
                  Intent intent = new Intent(context, DisplayActivity.class);
                  intent.putExtra("data", data);
  
                  if (intent.resolveActivity(getPackageManager()) != null) {
                      startActivity(intent);
                  }
              }
          });
      }
  
      @Override
      public void onResume() {
          //called after onStart() just before activity comes to the foreground
          super.onResume();
          new UpdateList().execute();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  
      class CustomListAdapter
              extends BaseAdapter {
          private Context context;
          private List&lt;RandomdataModel&gt; list;
          private LayoutInflater layoutInflater;
  
          CustomListAdapter(Context context) {
              this.context = context;
          }
  
          public void setList(List&lt;RandomdataModel&gt; list) {
              this.list = list;
          }
  
          @Override
          public int getCount() {
              return ((list == null) ? 0 : list.size());
          }
  
          @Override
          public Object getItem(int position) {
              //  In theory we should not be called if getCount() returned 0;
              return list.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          class ViewHolder {
              int position;
              TextView textView1;
              TextView textView2;
              Button button;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              if (DEBUG) {
                  Log.d(LOGTAG, "getView.position=" + position);
                  Log.d(LOGTAG, "getView.convertView=" + convertView);
              }
              if (list == null) {
                  //  In theory it should not happen but handle this in some graceful way.
                  //  Returning null will not produce graceful results.
  
  
                  //display dialog of no data found....
                  return null;
              }
  
              ViewHolder holder;
  
              if (convertView == null) {
                  convertView = getLayoutInflator().inflate(R.layout.list_view_items, null);
                  holder = new ViewHolder();
                  holder.textView1 = (TextView) convertView.findViewById(R.id.listitemTextIDValue);
                  holder.textView2 = (TextView) convertView.findViewById(R.id.listitemTextPartValue);
                  holder.button = (Button) convertView.findViewById(R.id.listitemButton);
                  holder.button.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
  
  
                      }
                  });
                  convertView.setTag(holder);
  
              } else {
                  holder = (ViewHolder) convertView.getTag();
              }
  
              RandomdataModel item = list.get(position);
              holder.textView1.setText("" + item.getId());
              holder.textView2.setText(item.getPart());
              holder.button.setText("Submit " + item.getId());
  
              return convertView;
          }
  
          private LayoutInflater getLayoutInflator() {
              if (layoutInflater == null) {
                  layoutInflater = (LayoutInflater)
                          this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              }
              return layoutInflater;
          }
      }
  
      class UpdateList
              extends AsyncTask&lt;Void, Void, List&lt;RandomdataModel&gt;&gt; {
          private final String LOGTAG = "Updating List";
          private final boolean DEBUG = true;
          private ProgressDialog dialog;
  
  
          @Override
          protected void onPreExecute() {
              //progressBarCircle.setVisibility(View.VISIBLE);
              dialog_fragment_loading = processingDialog("Loading Data...");
              dialog_fragment_loading.show(getSupportFragmentManager(), "loading_data");
          }
  
          @Override
          protected List&lt;RandomdataModel&gt; doInBackground(Void... params) {
              if (DEBUG) Log.d(LOGTAG, "**** doInBackground() STARTING");
  
              List&lt;RandomdataModel&gt; listData = new ArrayList&lt;&gt;();
  
              RandomdataModel data;
  
              int len = parts.length;
              try {
                  Thread.sleep(4000);
  
                  //loading data from array
                  for (int i = 0; i &lt; len; i++) {
                      data = new RandomdataModel();
                      data.setId(i);
                      data.setPart(parts[i]);
                      listData.add(data);
                  }
              } catch (Exception e) {
                  if (DEBUG) Log.d(LOGTAG, e.toString());
                  e.printStackTrace();
              }
  
              return listData;
          }
  
          @Override
          protected void onPostExecute(List&lt;RandomdataModel&gt; listData) {
              //close dialog
              dialog_fragment_loading.dismiss();
              listAdapter.setList(listData);
          }
      }
  
      public static ProcessingDialog processingDialog(String message) {
          final ProcessingDialog f = new ProcessingDialog();
          final Bundle args = new Bundle();
          args.putString("message", message);
          f.setArguments(args);
          return f;
      }    
  }
  </code></pre>
  
  <p>Been searching and searching and just having no luck, so figured I'd post my problem here.  Any help would be greatly appreciated!</p>