Source:
protected void onPostExecute(Object result) { if (!ActivityApp.this.isFinishing()) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this); alertDialogBuilder.setTitle(R.string.menu_whitelists); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); if (mListWhitelist.keySet().size() > 0) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View llWhitelists = inflater.inflate(R.layout.whitelists, null); Spinner spWhitelistType = (Spinner) llWhitelists.findViewById(R.id.spWhitelistType); ArrayAdapter<String> whitelistTypeAdapter = new ArrayAdapter<String>(ActivityApp.this, android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>( mListWhitelist.keySet())); spWhitelistType.setAdapter(whitelistTypeAdapter); spWhitelistType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mWhitelistAdapter.setType((String) parent.getSelectedItem()); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); ListView lvWhitelist = (ListView) llWhitelists.findViewById(R.id.lvWhitelist); lvWhitelist.setAdapter(mWhitelistAdapter); mWhitelistAdapter.setType((String) spWhitelistType.getSelectedItem()); alertDialogBuilder.setView(llWhitelists); } else { alertDialogBuilder.setMessage(R.string.msg_no_whitelists); } alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } super.onPostExecute(result); }

Target:
protected void onPostExecute(Object result) { if (!ActivityApp.this.isFinishing()) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this); alertDialogBuilder.setTitle(R.string.menu_whitelists); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); if (mListWhitelist.keySet().size() > 0) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View llWhitelists = inflater.inflate(R.layout.whitelists, null); Spinner spWhitelistType = (Spinner) llWhitelists.findViewById(R.id.spWhitelistType); ArrayAdapter<String> whitelistTypeAdapter = new ArrayAdapter<String>(ActivityApp.this, android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>( mListWhitelist.keySet())); spWhitelistType.setAdapter(whitelistTypeAdapter); spWhitelistType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mWhitelistAdapter.setType((String) parent.getSelectedItem()); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); ListView lvWhitelist = (ListView) llWhitelists.findViewById(R.id.lvWhitelist); lvWhitelist.setAdapter(mWhitelistAdapter); mWhitelistAdapter.setType((String) spWhitelistType.getSelectedItem()); alertDialogBuilder.setView(llWhitelists); } alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } super.onPostExecute(result); }