List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:asu.edu.msse.gpeddabu.moviedescriptions.MovieListAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String headerTitle = (String) getGroup(groupPosition); if (convertView == null) { android.util.Log.d(this.getClass().getSimpleName(), "in getGroupView null so creating new view"); LayoutInflater inflater = (LayoutInflater) this.parent .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.movie_group, null); }//w w w . j a v a 2s. co m TextView genreName = (TextView) convertView.findViewById(R.id.genreName); //android.util.Log.d(this.getClass().getSimpleName(),"in getGroupView text is: "+lblListHeader.getText()); genreName.setTypeface(null, Typeface.BOLD); genreName.setText(headerTitle); return convertView; }
From source file:com.diedrico.diedricoapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Inflate the content in the coordinator layout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.content_main, coordinatorLayout); //The toolbar of the app (the top one, with the title) toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w . j av a 2s . co m //Now we have to put the button in the toolbar and setup the NavigationView drawer = (DrawerLayout) findViewById(R.id.drawer_tabs_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); //Create, prepare and set the listener to the expandable List View(in the navigation View) expListView = (ExpandableListView) findViewById(R.id.expandableListView); prepareExapandableListNavigationView(); //To load the lists listAdapter = new ExpandableListAdapter(this, header, listDataChild); expListView.setAdapter(listAdapter); expListView.setOnChildClickListener(onExpandableClick()); //Prepare the ListView, load the items from itemsListView (in the navigation View) listView = (ListView) findViewById(R.id.listView); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.group_expandable, R.id.expandableGroupText, itemsListView); listView.setAdapter(arrayAdapter); listView.setOnItemClickListener(onListViewItemListener()); //The toolbar for the tabs toolbarTabs = (Toolbar) findViewById(R.id.toolbar_tabs); setSupportActionBar(toolbarTabs); //Setup the ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); setupViewPager(viewPager); //Setup the tabLayout in the toolbarTabs tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); }
From source file:fr.cph.chicago.adapter.BusAdapter.java
@Override public final View getView(final int position, View convertView, ViewGroup parent) { final BusRoute route = (BusRoute) getItem(position); TextView routeNameView = null;/* w w w .ja va 2 s. co m*/ TextView routeNumberView = null; LinearLayout detailsLayout = null; if (convertView == null) { LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_bus, null); final ViewHolder holder = new ViewHolder(); routeNameView = (TextView) convertView.findViewById(R.id.station_name); holder.routeNameView = routeNameView; routeNumberView = (TextView) convertView.findViewById(R.id.bike_availability); holder.routeNumberView = routeNumberView; detailsLayout = (LinearLayout) convertView.findViewById(R.id.route_details); holder.detailsLayout = detailsLayout; convertView.setTag(holder); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { holder.detailsLayout.setVisibility(LinearLayout.VISIBLE); mActivity.startRefreshAnimation(); new DirectionAsyncTask().execute(route, holder.detailsLayout); } }); } else { final ViewHolder holder = (ViewHolder) convertView.getTag(); routeNameView = holder.routeNameView; routeNumberView = holder.routeNumberView; detailsLayout = holder.detailsLayout; convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { holder.detailsLayout.setVisibility(LinearLayout.VISIBLE); mActivity.startRefreshAnimation(); new DirectionAsyncTask().execute(route, holder.detailsLayout); } }); } routeNameView.setText(route.getName()); routeNumberView.setText(route.getId()); return convertView; }
From source file:com.yairkukielka.feedhungry.ListViewEntryArrayAdapter.java
public ListViewEntryArrayAdapter(Activity context, int textViewResourceId, List<ListEntry> objects, ImageLoader imageLoader) {// w w w . j a v a 2s . co m super(context, textViewResourceId, objects); mImageLoader = imageLoader; this.context = context; animation = AnimationUtils.loadAnimation(context, R.anim.wave_scale); this.cards = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(PreferencesActivity.KEY_LIST_WITH_CARDS, false); layoutInflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageHeight = getContext().getResources().getDimensionPixelSize(R.dimen.item_image_height); imageWidth = getContext().getResources().getDimensionPixelSize(R.dimen.item_image_width); }
From source file:com.irccloud.android.fragment.LinksListFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context ctx = getActivity();//from w w w. ja va2s . co m if (ctx == null) return null; if (savedInstanceState != null && savedInstanceState.containsKey("event")) { try { event = mapper.readValue(savedInstanceState.getString("event"), JsonNode.class); } catch (IOException e) { e.printStackTrace(); } } LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.recyclerview, null); recyclerView = v.findViewById(R.id.recycler); recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext())); recyclerView.setVisibility(View.VISIBLE); adapter = new LinksAdapter(); recyclerView.setAdapter(adapter); v.findViewById(android.R.id.empty).setVisibility(View.GONE); Dialog d = new AlertDialog.Builder(ctx).setTitle("Servers linked to " + event.get("server").asText()) .setView(v).setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return d; }
From source file:com.android.calendar.selectcalendars.SelectCalendarsSimpleAdapter.java
public SelectCalendarsSimpleAdapter(Context context, int layout, Cursor c, FragmentManager fm) { super();/*from w w w. j a v a 2 s .co m*/ mLayout = layout; mOrientation = context.getResources().getConfiguration().orientation; initData(c); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mRes = context.getResources(); mColorCalendarVisible = mRes.getColor(R.color.calendar_visible); mColorCalendarHidden = mRes.getColor(R.color.calendar_hidden); mColorCalendarSecondaryVisible = mRes.getColor(R.color.calendar_secondary_visible); mColorCalendarSecondaryHidden = mRes.getColor(R.color.calendar_secondary_hidden); if (mScale == 0) { mScale = mRes.getDisplayMetrics().density; BOTTOM_ITEM_HEIGHT *= mScale; NORMAL_ITEM_HEIGHT *= mScale; } mCache = new CalendarColorCache(context, this); mFragmentManager = fm; mColorPickerDialog = (CalendarColorPickerDialog) fm.findFragmentByTag(COLOR_PICKER_DIALOG_TAG); mIsTablet = Utils.getConfigBool(context, R.bool.tablet_config); mColorViewTouchAreaIncrease = context.getResources() .getDimensionPixelSize(R.dimen.color_view_touch_area_increase); }
From source file:com.money.manager.ex.adapter.AllDataAdapter.java
public AllDataAdapter(Context context, Cursor c, TypeCursor typeCursor) { super(context, c, -1); this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.mApplication = (MoneyManagerApplication) context.getApplicationContext(); // create hash map mHeadersAccountIndex = new HashMap<Integer, Integer>(); // create sparse array boolean checked mCheckedPosition = new SparseBooleanArray(); mTypeCursor = typeCursor;// w w w .j a va 2 s . c om mCore = new Core(context); mContext = context; setFieldFromTypeCursor(); }
From source file:com.hpush.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//from w w w .j av a 2s . com try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.esri.arcgisruntime.sample.rgbrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState//from w w w .j a v a 2 s . c o m * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle rgbParameters = getArguments(); if (rgbParameters != null) { mMinR = rgbParameters.getInt("minR"); mMaxR = rgbParameters.getInt("maxR"); mMinG = rgbParameters.getInt("minG"); mMaxG = rgbParameters.getInt("maxG"); mMinB = rgbParameters.getInt("minB"); mMaxB = rgbParameters.getInt("maxB"); mPercentClipMin = rgbParameters.getInt("percent_clip_min"); mPercentClipMax = rgbParameters.getInt("percent_clip_max"); mStdDevFactor = rgbParameters.getInt("std_dev_factor"); mStretchType = (MainActivity.StretchType) rgbParameters.getSerializable("stretch_type"); Log.d("Incoming Parameters", "min r: " + mMinR + " max r: " + mMaxR + " min g: " + mMinG + " max g: " + mMaxG + " min b: " + mMinB + " max b: " + mMaxB); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") final View dialogView = inflater.inflate(R.layout.rgb_dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.rgb_rendering_parameters); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mMinR, mMaxR, mMinG, mMaxG, mMinB, mMaxB, mPercentClipMin, mPercentClipMax, mStdDevFactor, mStretchType); } }); // min max ui elements mMinRedTextView = (TextView) dialogView.findViewById(R.id.min_red_value_text_view); mMaxRedTextView = (TextView) dialogView.findViewById(R.id.max_red_value_text_view); mMinGreenTextView = (TextView) dialogView.findViewById(R.id.min_green_value_text_view); mMaxGreenTextView = (TextView) dialogView.findViewById(R.id.max_green_value_text_view); mMinBlueTextView = (TextView) dialogView.findViewById(R.id.min_blue_value_text_view); mMaxBlueTextView = (TextView) dialogView.findViewById(R.id.max_blue_value_text_view); mMinRedSeekBar = (SeekBar) dialogView.findViewById(R.id.min_red_seek_bar); mMaxRedSeekBar = (SeekBar) dialogView.findViewById(R.id.max_red_seek_bar); mMinGreenSeekBar = (SeekBar) dialogView.findViewById(R.id.min_green_seek_bar); mMaxGreenSeekBar = (SeekBar) dialogView.findViewById(R.id.max_green_seek_bar); mMinBlueSeekBar = (SeekBar) dialogView.findViewById(R.id.min_blue_seek_bar); mMaxBlueSeekBar = (SeekBar) dialogView.findViewById(R.id.max_blue_seek_bar); mMinRedSeekBar.setMax(255); mMaxRedSeekBar.setMax(255); mMinGreenSeekBar.setMax(255); mMaxGreenSeekBar.setMax(255); mMinBlueSeekBar.setMax(255); mMaxBlueSeekBar.setMax(255); mCurrMinRedTextView = (TextView) dialogView.findViewById(R.id.curr_min_red_text_view); mCurrMaxRedTextView = (TextView) dialogView.findViewById(R.id.curr_max_red_text_view); mCurrMinGreenTextView = (TextView) dialogView.findViewById(R.id.curr_min_green_text_view); mCurrMaxGreenTextView = (TextView) dialogView.findViewById(R.id.curr_max_green_text_view); mCurrMinBlueTextView = (TextView) dialogView.findViewById(R.id.curr_min_blue_text_view); mCurrMaxBlueTextView = (TextView) dialogView.findViewById(R.id.curr_max_blue_text_view); //update seek bar positions with current mMinMax values updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView); updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView); updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView); updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView); updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView); updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView); // percent clip ui elements mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view); mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view); mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar); mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar); mPercentClipMinSeekBar.setMax(99); mPercentClipMaxSeekBar.setMax(99); mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view); mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view); //update seek bar positions with current PercentClip updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); // standard deviation ui elements mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view); mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar); mStdDevSeekBar.setMax(3); mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view); //update seek bar position with current StandardDeviation updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); // set ui to previous selection if (mStretchType == MainActivity.StretchType.MIN_MAX) { setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) { setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) { setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); } // seek bar listeners mMinRedSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMinR = progress; updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView); // move max to march min if max goes below min if (mMaxR < mMinR) { mMaxR = mMinR; updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxRedSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMaxR = progress; updateSeekBar(mMaxRedSeekBar, mMaxR, mCurrMaxRedTextView); // move min to match max if min goes above max if (mMinR > mMaxR) { mMinR = mMaxR; updateSeekBar(mMinRedSeekBar, mMinR, mCurrMinRedTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMinGreenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMinG = progress; updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView); // move max to march min if max goes below min if (mMaxG < mMinG) { mMaxG = mMinG; updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxGreenSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMaxG = progress; updateSeekBar(mMaxGreenSeekBar, mMaxG, mCurrMaxGreenTextView); // move min to match max if min goes above max if (mMinG > mMaxG) { mMinG = mMaxG; updateSeekBar(mMinGreenSeekBar, mMinG, mCurrMinGreenTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMinBlueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMinB = progress; updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView); // move max to march min if max goes below min if (mMaxB < mMinB) { mMaxB = mMinB; updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxBlueSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMaxB = progress; updateSeekBar(mMaxBlueSeekBar, mMaxB, mCurrMaxBlueTextView); // move min to match max if min goes above max if (mMinB > mMaxB) { mMinB = mMaxB; updateSeekBar(mMinBlueSeekBar, mMinB, mCurrMinBlueTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMin = progress; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMax = 100 - mPercentClipMin; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMax = progress; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMin = 100 - mPercentClipMax; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStdDevFactor = progress; updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // stretch type spinner List<String> stretchTypeArray = new ArrayList<>(); stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0 stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1 stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2 ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.rgb_spinner_text_view, stretchTypeArray); Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner); stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter); stretchTypeSpinner.setSelection(mStretchType.ordinal()); stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mStretchType = MainActivity.StretchType.MIN_MAX; setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); break; case 1: mStretchType = MainActivity.StretchType.PERCENT_CLIP; setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); break; case 2: mStretchType = MainActivity.StretchType.STANDARD_DEVIATION; setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }