Example usage for android.widget Spinner setAdapter

List of usage examples for android.widget Spinner setAdapter

Introduction

In this page you can find the example usage for android.widget Spinner setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

Usage

From source file:com.secretparty.app.BuzzDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View rootView = getActivity().getLayoutInflater().inflate(R.layout.buzz_player, null);
    SharedPreferences prefs = getActivity().getPreferences(Activity.MODE_PRIVATE);
    Bundle b = getArguments();//from   ww  w .ja  v  a2  s.  c o  m
    final int buzzeeId = b.getInt(BUZZEE_ID, -1);
    final int buzzerId = prefs.getInt(getString(R.string.SP_user_id), -1);
    int thematicId = b.getInt(ThematicDetailedFragment.THEMATIC_ID, -1);
    if (thematicId == -1 || buzzeeId == -1 || buzzerId == -1) {
        Log.e(TAG, "thematic/buzzer/buzzee id = -1");
    }
    final List<Secret> secrets = mCallback.getThematicRepository().get(thematicId).getSecrets();

    Spinner s = (Spinner) rootView.findViewById(R.id.S_secrets);
    ArrayAdapter<Secret> adapter = new ArrayAdapter<Secret>(getActivity(), android.R.layout.simple_spinner_item,
            secrets);
    s.setAdapter(adapter);
    s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            BuzzDialog.this.mSelectedSecretId = secrets.get(i).getId();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(rootView).setTitle(R.string.party_buzz_dialog)
            .setPositiveButton(R.string.buzz, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dismiss();
                    mCallback.onBuzzPlayer(mCallback.getParty().getId(), buzzerId, buzzeeId, mSelectedSecretId);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Toast.makeText(getActivity(), R.string.party_join_cancel, Toast.LENGTH_LONG).show();
                    dismiss();
                }
            });
    return builder.create();

}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerYear(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_year));
    spinner.setAdapter(adapter);
    adapter.clear();//from  w w w .  j  a va  2 s.co m

    String yyyy = selected.substring(0, selected.indexOf("/"));
    if (yyyy.equals("****")) {
        String tyy = sdfDate.format(System.currentTimeMillis());
        yyyy = tyy.substring(0, tyy.indexOf("/"));
    }
    int year = Integer.parseInt(yyyy);
    adapter.add(yyyy);
    adapter.add("" + (year + 1));
    spinner.setSelection(0);

}

From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bird_details_tab_layout);

    final String latinSpecies = getIntent().getExtras().getString(BirdListFragment.LATIN_SPECIES);
    final String englishSpecies = getIntent().getExtras().getString(BirdListFragment.ENGLISH_SPECIES);
    final String swedishFamily = getIntent().getExtras().getString(BirdListFragment.SWEDISH_FAMILY);

    Bundle bundle = new Bundle(1);
    bundle.putString(BirdSpeciesWebFragment.ENGLISH_SPECIES, englishSpecies);
    bundle.putString(BirdSpeciesXenoCantoPlayerFragment.LATIN_SPECIES, latinSpecies);

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);

    tabHost.addTab(//from w ww .j av  a 2  s .  c  o  m
            tabHost.newTabSpec("Wikipedia").setIndicator(getText(R.string.tab_wikipedia),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesWebFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Flickr").setIndicator(getText(R.string.tab_photos),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFlickrGalleryFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("xeno-canto").setIndicator(getText(R.string.tab_sounds),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesXenoCantoPlayerFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Statistik").setIndicator(getText(R.string.tab_facts),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFactsFragment.class, bundle);
    tabHost.addTab(tabHost.newTabSpec("Karta").setIndicator(getText(R.string.tab_map),
            getResources().getDrawable(android.R.drawable.star_on)), MapFragment.class, bundle);

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    LinearLayout linearLayout = (LinearLayout) tabWidget.getParent();
    HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
    horizontalScrollView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    linearLayout.addView(horizontalScrollView, 0);
    linearLayout.removeView(tabWidget);
    horizontalScrollView.addView(tabWidget);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    BirdListSpinnerAdapter birdListSpinnerAdapter = createAdapter();
    birdListSpinnerAdapter.setFilterFamily(swedishFamily);
    birdListSpinnerAdapter.initialize(getSharedPreferences(Constants.BIRD_APP_SETTINGS, Context.MODE_PRIVATE));
    if (BirdListAdapter.SortOption.PHYLOGENETIC.equals(birdListSpinnerAdapter.getSortOption())) {
        birdListSpinnerAdapter.setSortOption(BirdListAdapter.SortOption.SWEDISH);
    }

    birdListSpinnerAdapter.refresh();
    birdListSpinnerAdapter.notifyDataSetChanged();

    Spinner spinner = new Spinner(this);
    spinner.setId(R.id.birdspecies_spinner);
    spinner.setAdapter(birdListSpinnerAdapter);
    spinner.setGravity(Gravity.FILL_HORIZONTAL);

    spinner.setSelection(birdListSpinnerAdapter.getPosition(new Bird(latinSpecies)));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            BirdSpeciesFragment fragment = (BirdSpeciesFragment) getSupportFragmentManager()
                    .findFragmentByTag(tabHost.getCurrentTabTag());
            Spinner spinner = (Spinner) getActionBar().getCustomView().findViewById(R.id.birdspecies_spinner);
            fragment.loadBird((Bird) spinner.getSelectedItem());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    getActionBar().setCustomView(spinner);
    getActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);

}

From source file:com.esri.arcgisruntime.sample.hillshaderenderer.ParametersDialogFragment.java

/**
 * Builds a parameter dialog box with values pulled through from MainActivity.
 * @param savedInstanceState bundle holding previous activity's saved state
 * @return create parameter dialog box/*from   w  w w  .j  a  v a 2  s.  c o m*/
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Bundle hillshadeParameters = getArguments();
    if (hillshadeParameters != null) {
        mAltitude = hillshadeParameters.getInt("altitude");
        mAzimuth = hillshadeParameters.getInt("azimuth");
        mSlopeType = (SlopeType) hillshadeParameters.getSerializable("slope_type");
    }

    AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext());
    @SuppressLint("InflateParams")
    View dialogView = inflater.inflate(R.layout.hillshade_dialog_box, null);
    paramDialog.setView(dialogView);
    paramDialog.setTitle(R.string.dialog_title);
    paramDialog.setNegativeButton("Cancel", (dialog, which) -> dismiss());
    paramDialog.setPositiveButton("Render", (dialog, which) -> {
        ParametersListener activity = (ParametersListener) getActivity();
        activity.returnParameters(mAltitude, mAzimuth, mSlopeType);
    });

    mCurrAltitudeTextView = dialogView.findViewById(R.id.hillshade_curr_altitude_text);
    SeekBar altitudeSeekBar = dialogView.findViewById(R.id.hillshade_altitude_seek_bar);
    altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90
    //set initial altitude value
    updateAltitudeSeekBar(altitudeSeekBar);
    altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAltitude = progress;
            updateAltitudeSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    mCurrAzimuthTextView = dialogView.findViewById(R.id.hillshade_curr_azimuth_text);
    SeekBar azimuthSeekBar = dialogView.findViewById(R.id.hillshade_azimuth_seek_bar);
    azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360
    //set initial azimuth value
    updateAzimuthSeekBar(azimuthSeekBar);
    azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            mAzimuth = progress;
            updateAzimuthSeekBar(seekBar);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    List<String> slopeTypeArray = new ArrayList<>();
    slopeTypeArray.add("None"); //ordinals:0
    slopeTypeArray.add("Degree"); //1
    slopeTypeArray.add("Percent rise"); //2
    slopeTypeArray.add("Scaled"); //3

    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.hillshade_spinner_text_view,
            slopeTypeArray);

    Spinner slopeTypeSpinner = dialogView.findViewById(R.id.hillshade_slope_type_spinner);
    slopeTypeSpinner.setAdapter(spinnerAdapter);
    slopeTypeSpinner.setSelection(mSlopeType.ordinal());
    slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                mSlopeType = SlopeType.NONE;
                break;
            case 1:
                mSlopeType = SlopeType.DEGREE;
                break;
            case 2:
                mSlopeType = SlopeType.PERCENT_RISE;
                break;
            case 3:
                mSlopeType = SlopeType.SCALED;
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    return paramDialog.create();
}

From source file:com.github.michalbednarski.intentslab.browser.FetcherOptionsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Inflate and get views
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.browse_components_top_options, null, false);
    mTopLayout = (ViewGroup) view.findViewById(R.id.top_layout);
    Spinner fetcherTypeSpinner = (Spinner) mTopLayout.findViewById(R.id.fetcher_type);
    mTopLayoutWithoutFetcherChildCount = mTopLayout.getChildCount();

    // Prepare fetcher spinner
    fetcherTypeSpinner.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            FetcherManager.getFetcherNames(getActivity())));
    fetcherTypeSpinner.setSelection(FetcherManager.getFetcherIndex(mFetcher));
    fetcherTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//from   w  ww.j a  v a 2 s  .c  o  m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (FetcherManager.getFetcherIndex(mFetcher) != position) {
                mFetcher = FetcherManager.createNewFetcherByIndex(position);
                createFetcherConfigurationView();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // Spinner won't have nothing selected
        }
    });

    // Prepare fetcher configuration
    createFetcherConfigurationView();

    // Create dialog
    return new AlertDialog.Builder(getActivity()).setView(view)
            .setPositiveButton(R.string.set_custom_filter, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mFetcher.updateFromConfigurationForm(FetcherOptionsDialog.this);
                    ((BrowseComponentsFragment) getTargetFragment()).setFetcher(mFetcher);
                }
            }).create();
}

From source file:com.mbientlab.metawear.app.popup.AccelerometerSettings.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    getDialog().setTitle("Accelerometer Settings");

    Spinner spinnerObj;

    spinnerObj = (Spinner) view.findViewById(R.id.spinner1);
    spinnerObj.setAdapter(new ArrayAdapter<TapType>(getActivity(), R.layout.command_row, R.id.command_name,
            TapType.values()));//from  w  w w  .j  a  v  a  2s  .  c o m
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyTapType(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.tapTypePos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner2);
    spinnerObj.setAdapter(
            new ArrayAdapter<Axis>(getActivity(), R.layout.command_row, R.id.command_name, Axis.values()));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyTapAxis(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.tapAxisPos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner3);
    spinnerObj.setAdapter(
            new ArrayAdapter<Axis>(getActivity(), R.layout.command_row, R.id.command_name, Axis.values()));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyShakeAxis(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.shakeAxisPos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner4);
    spinnerObj.setAdapter(new ArrayAdapter<FullScaleRange>(getActivity(), R.layout.command_row,
            R.id.command_name, FullScaleRange.values()));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyDataRange(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.fsrPos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner5);
    spinnerObj.setAdapter(new ArrayAdapter<OutputDataRate>(getActivity(), R.layout.command_row,
            R.id.command_name, OutputDataRate.values()));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifySamplingRate(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.odrPos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner6);
    spinnerObj.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.command_row, R.id.command_name,
            new String[] { "Free Fall", "Motion" }));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyMovementType(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.movementPos());

    spinnerObj = (Spinner) view.findViewById(R.id.spinner7);
    spinnerObj.setAdapter(ArrayAdapter.createFromResource(getActivity(), R.array.firmware_version_array,
            android.R.layout.simple_spinner_item));
    spinnerObj.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            accelConfig.modifyFirmwareVersion(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinnerObj.setSelection(accelConfig.firmwarePos());
}

From source file:com.rightscale.app.dashboard.ShowServerMonitoring.java

public void consumeContent(Cursor cursor, String tag) {
    super.consumeContent(cursor, tag);

    if (tag == MONITORS) {
        _cursor = cursor;//from  w  ww . ja va2 s  .  c  o m
        startManagingCursor(cursor);
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item,
                cursor, FROM, TO);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        Spinner spinner = (Spinner) findViewById(R.id.show_server_monitoring_spinner);
        spinner.setEnabled(true);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                int colHref = _cursor.getColumnIndexOrThrow("href");
                _cursor.moveToPosition(position);
                String href = _cursor.getString(colHref);
                showGraph(href, DEFAULT_SIZE, DEFAULT_PERIOD);
            }

            public void onNothingSelected(AdapterView<?> arg0) {
                //TODO: clear the monitoring graph (fade out, oooh!)
            }
        });
    }
}

From source file:com.example.community_list_post.posting.HomeFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Create the spiiner drop down menu
    Spinner dropdown = (Spinner) getView().findViewById(R.id.spinner_home);
    String[] items = new String[] { "General", "Events", "Crime", "Missing", "Market", "Jobs", "Specials" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            items);/*from w w w . j  a  v a2  s  .c o m*/
    dropdown.setAdapter(adapter);

    EditText postHome = (EditText) getView().findViewById(R.id.post_home);

    Button home_button = (Button) getView().findViewById(R.id.post_home_button);

}

From source file:com.tapchatapp.android.app.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int currentIndex = getCurrentIndex();

    switch (item.getItemId()) {
    case R.id.join_channel: {
        View dialogView = this.getLayoutInflater().inflate(R.layout.dialog_join_channel, null);
        Spinner serverSpinner = (Spinner) dialogView.findViewById(R.id.server);
        serverSpinner.setAdapter(ServerSpinnerAdapter.create(this, getService()));
        serverSpinner.setSelection(currentIndex);
        new AlertDialog.Builder(this).setTitle(R.string.join_channel).setView(dialogView)
                .setPositiveButton(R.string.join, new DialogInterface.OnClickListener() {
                    @Override/*from w  w  w.jav a2  s.  c  o  m*/
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Spinner serverSpinner = (Spinner) ((AlertDialog) dialogInterface)
                                .findViewById(R.id.server);
                        Map serverItem = (Map) serverSpinner.getSelectedItem();

                        long connectionId = (Long) serverItem.get("id");
                        Connection connection = getService().getConnection(connectionId);

                        EditText channelEditText = (EditText) ((AlertDialog) dialogInterface)
                                .findViewById(R.id.channel);
                        connection.join(channelEditText.getText().toString(), null);
                    }

                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }

    case R.id.message_user: {
        View dialogView = this.getLayoutInflater().inflate(R.layout.dialog_message_user, null);
        Spinner serverSpinner = (Spinner) dialogView.findViewById(R.id.server);
        serverSpinner.setAdapter(ServerSpinnerAdapter.create(this, getService()));
        serverSpinner.setSelection(currentIndex);

        new AlertDialog.Builder(this).setTitle(R.string.send_message).setView(dialogView)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Spinner serverSpinner = (Spinner) ((AlertDialog) dialogInterface)
                                .findViewById(R.id.server);
                        Map serverItem = (Map) serverSpinner.getSelectedItem();

                        long connectionId = (Long) serverItem.get("id");
                        Connection connection = getService().getConnection(connectionId);

                        EditText nickEditText = (EditText) ((AlertDialog) dialogInterface)
                                .findViewById(R.id.nick);
                        connection.say(nickEditText.getText().toString(), null, null);
                    }

                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }

    case R.id.preferences:
        startActivity(new Intent(this, PreferencesActivity.class));
        return true;

    case R.id.contribute:
        Intent intent = new Intent(Intent.ACTION_VIEW, CONTRIBUTE_URI);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        return true;
    }
    return false;
}

From source file:com.tassadar.multirommgr.installfragment.InstallCard.java

@Override
public View getCardContent(Context context) {
    m_view = LayoutInflater.from(context).inflate(R.layout.install_card, null);

    Resources res = m_view.getResources();

    CheckBox b = (CheckBox) m_view.findViewById(R.id.install_multirom);
    b.setText(res.getString(R.string.install_multirom, m_manifest.getMultiromVersion()));
    b.setChecked(m_manifest.hasMultiromUpdate());
    b.setOnCheckedChangeListener(this);

    b = (CheckBox) m_view.findViewById(R.id.install_recovery);
    if (m_manifest.getRecoveryFile() != null) {
        final Date rec_date = m_manifest.getRecoveryVersion();
        final String recovery_ver = Recovery.DISPLAY_FMT.format(rec_date);
        b.setText(res.getString(R.string.install_recovery, recovery_ver));
        b.setChecked(m_manifest.hasRecoveryUpdate());
        b.setOnCheckedChangeListener(this);

        // Force user to install recovery if not yet installed - it is needed to flash ZIPs
        if (m_manifest.hasRecoveryUpdate() && m_forceRecovery) {
            b.append(Html.fromHtml(res.getString(R.string.required)));
            b.setClickable(false);//  w  ww .ja  v  a2 s  .  c o  m
        }
    } else {
        b.setChecked(false);
        b.setVisibility(View.GONE);
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
            android.R.layout.simple_spinner_dropdown_item);
    adapter.addAll(m_manifest.getKernels().keySet());
    Spinner s = (Spinner) m_view.findViewById(R.id.kernel_options);
    s.setAdapter(adapter);
    s.setEnabled(false);
    s.setSelection(getDefaultKernel());

    b = (CheckBox) m_view.findViewById(R.id.install_kernel);
    b.setOnCheckedChangeListener(this);
    b.setEnabled(!adapter.isEmpty());
    b.setChecked(!adapter.isEmpty() && m_manifest.hasKernelUpdate());

    Button install_btn = (Button) m_view.findViewById(R.id.install_btn);
    install_btn.setOnClickListener(this);

    ImageButton changelog_btn = (ImageButton) m_view.findViewById(R.id.changelog_btn);
    if (m_manifest.getChangelogs() == null || m_manifest.getChangelogs().length == 0)
        changelog_btn.setVisibility(View.GONE);
    else
        changelog_btn.setOnClickListener(this);

    if (m_savedState != null)
        restoreInstanceState();

    enableInstallBtn();
    return m_view;
}