List of usage examples for android.widget ArrayAdapter setDropDownViewResource
public void setDropDownViewResource(@LayoutRes int resource)
Sets the layout resource to create the drop down views.
From source file:eu.power_switch.gui.fragment.alarm_clock.StockAlarmClockFragment.java
@Override public void onCreateViewEvent(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_stock_alarm_clock, container, false); setHasOptionsMenu(true);// ww w . j a va 2 s . c om final RecyclerViewFragment recyclerViewFragment = this; Switch switchOnOff = (Switch) rootView.findViewById(R.id.switch_on_off); switchOnOff.setChecked(SmartphonePreferencesHandler.getStockAlarmClockEnabled()); switchOnOff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (buttonView.isPressed()) { SmartphonePreferencesHandler.setStockAlarmClockEnabled(isChecked); } } }); spinnerEventType = (Spinner) rootView.findViewById(R.id.spinner_sleep_as_android_event); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.stock_alarm_clock_event_names, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerEventType.setAdapter(adapter); SpinnerInteractionListener spinnerInteractionListener = new SpinnerInteractionListener() { @Override public void onItemSelectedByUser(AdapterView<?> parent, View view, int pos, long id) { updateUI(); } }; spinnerEventType.setOnItemSelectedListener(spinnerInteractionListener); spinnerEventType.setOnTouchListener(spinnerInteractionListener); recyclerViewActions = (RecyclerView) rootView.findViewById(R.id.recyclerView); recyclerViewAdapter = new ActionRecyclerViewAdapter(getContext(), actions); recyclerViewAdapter.setOnDeleteClickListener(new ActionRecyclerViewAdapter.OnItemClickListener() { @Override public void onItemClick(View itemView, final int position) { new AlertDialog.Builder(getContext()).setTitle(R.string.delete).setMessage(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { actions.remove(position); DatabaseHandler.setAlarmActions( Event.getById(spinnerEventType.getSelectedItemPosition()), actions); StatusMessageHandler.showInfoMessage(recyclerViewFragment.getRecyclerView(), R.string.action_removed, Snackbar.LENGTH_LONG); } catch (Exception e) { StatusMessageHandler.showErrorMessage(recyclerViewFragment.getRecyclerView(), e); } recyclerViewAdapter.notifyDataSetChanged(); } }).setNeutralButton(android.R.string.cancel, null).show(); } }); recyclerViewActions.setAdapter(recyclerViewAdapter); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(getSpanCount(), StaggeredGridLayoutManager.VERTICAL); recyclerViewActions.setLayoutManager(layoutManager); addActionFAB = (FloatingActionButton) rootView.findViewById(R.id.add_fab); addActionFAB.setImageDrawable(IconicsHelper.getAddIcon(getActivity(), ContextCompat.getColor(getActivity(), android.R.color.white))); addActionFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AddStockAlarmClockEventActionDialog addAlarmEventActionDialog = AddStockAlarmClockEventActionDialog .newInstance(spinnerEventType.getSelectedItemPosition()); addAlarmEventActionDialog.setTargetFragment(recyclerViewFragment, 0); addAlarmEventActionDialog.show(getActivity().getSupportFragmentManager(), null); } }); // BroadcastReceiver to get notifications from background service if room data has changed broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(this, "received intent: " + intent.getAction()); if (LocalBroadcastConstants.INTENT_ALARM_EVENT_ACTION_ADDED.equals(intent.getAction())) { updateUI(); } else { updateUI(); } } }; }
From source file:com.example.moneymeterexample.AddExpenseActivity.java
private void loadCategorySpinnerValues() { DataBaseHelper db;//from w ww . j av a 2s . c o m db = new DataBaseHelper(this); cat_list = db.getCategories(); if (cat_list.size() == 0) cat_list.add("No Selection"); cat_list.add("New..."); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, cat_list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); category.setAdapter(dataAdapter); category.setPrompt("Choose a category"); }
From source file:com.amagi82.kerbalspaceapp.Settings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); getActionBar().setTitle(R.string.title_activity_settings); SeekBar clearance = (SeekBar) findViewById(R.id.seekBarClearance); SeekBar margins = (SeekBar) findViewById(R.id.seekBarMargins); SeekBar inclination = (SeekBar) findViewById(R.id.seekBarInclination); mClearance = (TextView) findViewById(R.id.tvClearance); mMargins = (TextView) findViewById(R.id.tvMargins); mInclination = (TextView) findViewById(R.id.tvInclination); chooseLanguage = (Spinner) findViewById(R.id.spinnerLanguages); SharedPreferences prefs = getSharedPreferences("settings", MODE_PRIVATE); mClearanceValue = prefs.getInt("mClearanceValue", 1000); mMarginsValue = prefs.getInt("mMarginsValue", 10); mInclinationValue = prefs.getInt("mInclinationValue", 30); chooseLanguage.setSelection(prefs.getInt("language", 0)); // Set up spinner ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActionBar().getThemedContext(), R.array.languages, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); chooseLanguage.setAdapter(adapter);//from w w w . ja v a 2 s . co m // @formatter:off if (Locale.getDefault().getLanguage().equals("en")) chooseLanguage.setSelection(0); if (Locale.getDefault().getLanguage().equals("fr")) chooseLanguage.setSelection(1); if (Locale.getDefault().getLanguage().equals("de")) chooseLanguage.setSelection(2); if (Locale.getDefault().getLanguage().equals("es")) chooseLanguage.setSelection(3); if (Locale.getDefault().getLanguage().equals("ru")) chooseLanguage.setSelection(4); // Set seekbar progress clearance.setProgress(mClearanceValue); margins.setProgress(mMarginsValue); inclination.setProgress(mInclinationValue); // Display values mClearance.setText(mClearanceValue + "m"); mMargins.setText(mMarginsValue + "%"); setInclinationText(); clearance.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String value = NumberFormat.getNumberInstance(Locale.getDefault()).format(progress); mClearance.setText(value + "m"); mClearanceValue = progress; } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); margins.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMargins.setText(progress + "%"); mMarginsValue = progress; } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); inclination.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mInclinationValue = progress; setInclinationText(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); chooseLanguage.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { language = langCode[chooseLanguage.getSelectedItemPosition()]; onConfigurationChanged(getResources().getConfiguration()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.andrasta.dashi.MainActivity.java
private void createCameraSizesAdapter() { Pair<String, List<Size>> pair = CameraUtils.getMainCameraImageSizes(this, ImageFormat.YUV_420_888); if (pair == null) { throw new RuntimeException("No camera sizes"); }/* www . j av a 2 s . c om*/ cameraRecSize = pair.second.get(0); updatePolygonView(); ArrayAdapter<Size> adapter = new ArrayAdapter<>(this, R.layout.simple_spinner_item, pair.second); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); }
From source file:com.adithya321.sharesanalysis.fragments.SalesShareFragment.java
private void setRecyclerViewAdapter() { sharesList = databaseHandler.getShares(); final List<Purchase> salesList = databaseHandler.getSales(); PurchaseShareAdapter purchaseAdapter = new PurchaseShareAdapter(getContext(), salesList); purchaseAdapter.setOnItemClickListener(new PurchaseShareAdapter.OnItemClickListener() { @Override// w ww . j a va2 s. co m public void onItemClick(View itemView, int position) { final Purchase purchase = salesList.get(position); final Dialog dialog = new Dialog(getActivity()); dialog.setTitle("Edit Share Sale"); dialog.setContentView(R.layout.dialog_sell_share_holdings); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); int pos = 0; for (int i = 0; i < sharesList.size(); i++) { shares.add(sharesList.get(i).getName()); if (sharesList.get(i).getName().equals(purchase.getName())) pos = i; } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(pos); spinner.setVisibility(View.VISIBLE); final EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); final EditText price = (EditText) dialog.findViewById(R.id.selling_price); quantity.setText(String.valueOf(purchase.getQuantity())); price.setText(String.valueOf(purchase.getPrice())); Calendar calendar = Calendar.getInstance(); calendar.setTime(purchase.getDate()); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(SalesShareFragment.this); Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn); sellShareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Purchase p = new Purchase(); p.setId(purchase.getId()); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); p.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } try { p.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } try { p.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show(); return; } p.setType("sell"); p.setName(spinner.getSelectedItem().toString()); databaseHandler.updatePurchase(p); setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); salesRecyclerView.setHasFixedSize(true); salesRecyclerView.setAdapter(purchaseAdapter); salesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); }
From source file:com.remdo.app.EditDeviceActivity.java
private void setsnniper() { Spinner spinner = (Spinner) findViewById(R.id.spinner); // Spinner click listener spinner.setOnItemSelectedListener((OnItemSelectedListener) this); // Spinner Drop down elements List<String> categories = new ArrayList<String>(); if (dh.ODNetworkExists()) { if (EditMode == true) { if (currentDevice.odType == 1) { categories.add("ODNetwork"); categories.add("ODControl"); } else { categories.add("ODControl"); }/*from w w w. j a va2s .c om*/ } else { categories.add("ODControl"); } } else { if (EditMode == true) { categories.add("ODControl"); categories.add("ODNetwork"); } else { categories.add("ODNetwork"); categories.add("ODControl"); } } // Creating adapter for spinner ArrayAdapter<String> odTypesAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); // Drop down layout style - list view with radio button odTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // attaching data adapter to spinner spinner.setAdapter(odTypesAdapter); //odTypesAdapter.setDropDownViewResource(currentDevice.odType); }
From source file:com.adithya321.sharesanalysis.fragments.SalesShareFragment.java
@Nullable @Override//w w w . j a v a2s. c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_sales, container, false); databaseHandler = new DatabaseHandler(getContext()); salesRecyclerView = (RecyclerView) root.findViewById(R.id.sales_recycler_view); setRecyclerViewAdapter(); FloatingActionButton sellShareFab = (FloatingActionButton) root.findViewById(R.id.sell_share_fab); sellShareFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Sell Share Holdings"); dialog.setContentView(R.layout.dialog_sell_share_holdings); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); for (Share share : sharesList) { shares.add(share.getName()); } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn); sellShareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Purchase purchase = new Purchase(); purchase.setId(databaseHandler.getNextKey("purchase")); purchase.setName(spinner.getSelectedItem().toString()); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); purchase.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); try { purchase.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } EditText price = (EditText) dialog.findViewById(R.id.selling_price); try { purchase.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Selling Price", Toast.LENGTH_SHORT).show(); return; } purchase.setType("sell"); databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase); setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); return root; }
From source file:ca.farrelltonsolar.classic.DayLogChart.java
private void setupSpinner(MenuItem item) { try {/*from w w w . jav a 2 s. c o m*/ item.setVisible(true); item.setActionView(R.layout.action_chart_select); View view = MenuItemCompat.getActionView(item); if (view instanceof Spinner) { Spinner spinner = (Spinner) view; String[] itemArray = getResources().getStringArray(R.array.day_log_chart_selection); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_spinner_item, itemArray); //selected item will look like a spinner set from XML spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerArrayAdapter); spinner.setSelection(MonitorApplication.chargeControllers().getCurrentChargeController() .getDayLogMenuSelection(), false); spinner.setOnItemSelectedListener( new OnItemSelectedListenerWrapper(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { chartView.clearSeries(); if (position < mSeries.size()) { MonitorApplication.chargeControllers().getCurrentChargeController() .setDayLogMenuSelection(position); chartView.addSeries(mSeries.get(position)); } } @Override public void onNothingSelected(AdapterView<?> parent) { } })); } } catch (Exception ex) { Log.w(getClass().getName(), String.format("Day Log Chart failed to load setupSpinner %s ex: %s", Thread.currentThread().getName(), ex)); } }
From source file:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new CustomAlertDialogBuilder(mContext); builder.setTitle(R.string.text_tool_dialog_title); final View view = inflater.inflate(R.layout.dialog_text_tool, null); mTextEditText = (EditText) view.findViewById(R.id.text_tool_dialog_input_text); mTextEditText.addTextChangedListener(new TextWatcher() { @Override//w w w . j av a 2 s . c o m public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String text = mTextEditText.getText().toString(); mOnTextToolDialogChangedListener.setText(text); mText = text; } }); mFontSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_font); ArrayAdapter<CharSequence> fontAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_font_array, android.R.layout.simple_spinner_item); fontAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mFontSpinner.setAdapter(fontAdapter); mFontSpinner.setBackgroundColor(Color.GRAY); mFontSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String font = parent.getItemAtPosition(position).toString(); mOnTextToolDialogChangedListener.setFont(font); mFontIndex = position; if (mFontSpinnerInitialized) hideKeyboard(); else mFontSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mUnderlinedToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_underlined); mUnderlinedToggleButton.setTextOn(Html .fromHtml("<u>" + getResources().getString(R.string.text_tool_dialog_underline_shortcut) + "</u>")); mUnderlinedToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean underlined = mUnderlinedToggleButton.isChecked(); mOnTextToolDialogChangedListener.setUnderlined(underlined); mUnderlined = underlined; hideKeyboard(); } }); mItalicToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_italic); mItalicToggleButton.setTextOn(Html .fromHtml("<i>" + getResources().getString(R.string.text_tool_dialog_italic_shortcut) + "</i>")); mItalicToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean italic = mItalicToggleButton.isChecked(); mOnTextToolDialogChangedListener.setItalic(italic); mItalic = italic; hideKeyboard(); } }); mBoldToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_bold); mBoldToggleButton.setTextOn( Html.fromHtml("<b>" + getResources().getString(R.string.text_tool_dialog_bold_shortcut) + "</b>")); mBoldToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean bold = mBoldToggleButton.isChecked(); mOnTextToolDialogChangedListener.setBold(bold); mBold = bold; hideKeyboard(); } }); mTextSizeSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_text_size); ArrayAdapter<CharSequence> textSizeAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_size_array, android.R.layout.simple_spinner_item); textSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTextSizeSpinner.setAdapter(textSizeAdapter); mTextSizeSpinner.setBackgroundColor(Color.GRAY); mTextSizeSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { int size = Integer.parseInt(parent.getItemAtPosition(position).toString()); mOnTextToolDialogChangedListener.setTextSize(size); mTextSizeIndex = position; if (mTextSizeSpinnerInitialized) hideKeyboard(); else mTextSizeSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setView(view); builder.setNeutralButton(R.string.done, this); Dialog textDialog = builder.create(); WindowManager.LayoutParams window_params = textDialog.getWindow().getAttributes(); textDialog.getWindow().setDimAmount(0.0f); textDialog.getWindow().setAttributes(window_params); return textDialog; }
From source file:com.commonslab.commonslab.Fragments.UploadToCommonsFragment.java
private void setupView() { uploadTitleTextView = (AutoCompleteTextView) getActivity().findViewById(R.id.upload_title); uploadDescriptionTextView = (AutoCompleteTextView) getActivity().findViewById(R.id.upload_description); uploadCommentTextView = (AutoCompleteTextView) getActivity().findViewById(R.id.upload_comment); upload_license = (Spinner) getActivity().findViewById(R.id.upload_license); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.Licenses, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); upload_license.setAdapter(adapter);/* ww w . jav a2 s . c o m*/ coverImage = (ImageView) getActivity().findViewById(R.id.uploadImageView); coverImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mediaType == Media.AUDIO) { if (mediaPlayer == null) { try { playAudio(contributionPath); } catch (IOException e) { e.printStackTrace(); } } else if (mediaPlayer != null) { mediaPlayer.stop(); //start playing from the start try { playAudio(contributionPath); } catch (IOException e) { e.printStackTrace(); } } } else if (mediaType == Media.VIDEO) { playVideo(); } else { //Image Intent intent = new Intent(getActivity(), ImageDetailsActivity.class); intent.putExtra("ImageURL", contributionPath); startActivity(intent); } } }); cancelButton = (Button) getActivity().findViewById(R.id.upload_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { exitFragment(); } }); uploadButton = (Button) getActivity().findViewById(R.id.uploadButton); uploadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { uploadMedia(); } }); setFonts(); }