private void loadSpinnerData() { Boolean isThereData = null; Cursor cursor = getActivity() .getContentResolver() .query(MyContentProvider.CONTENT_URI_VIEW_USER_APPLICATION, null, null, null, null); isThereData = cursor != null && cursor.moveToFirst(); mAdapter = new SimpleCursorAdapter( getActivity(), R.layout.spinner_item_row_selected_fill, null, new String[] {MyContentProvider.APPLICATION_TYPE_NAME}, new int[] {R.id.spinnerDropdownItem}, 0); mAdapter.setDropDownViewResource(R.layout.spinner_item_row_dropdown); appSpinner.setBackgroundColor(getResources().getColor(android.R.color.transparent)); if (isThereData) { appSpinner.setAdapter(mAdapter); getActivity().getLoaderManager().initLoader(0, null, this); } else { appSpinner.setAdapter( new NothingSelectedSpinnerAdapter( mAdapter, R.layout.spinner_item_row_prompt, // R.layout.contact_spinner_nothing_selected_dropdown, // Optional getActivity())); getActivity().getLoaderManager().initLoader(0, null, this); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.staffmessage); capspin = (Spinner) this.findViewById(R.id.capspin); emailedit = (EditText) this.findViewById(R.id.emailedit); seekRate = (SeekBar) this.findViewById(R.id.seekRate); sendproposal = (ImageButton) this.findViewById(R.id.sendProposalButton); seekRateValue = (TextView) this.findViewById(R.id.seekRateValue); messagebox = (EditText) this.findViewById(R.id.proposalEdit); proposalSubject = (EditText) this.findViewById(R.id.proposalSubject); seekRate.setMax(100); seekRate.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { int real_value = (seekRate.getProgress() + 8); value = Integer.toString(real_value); seekRateValue.setText(" $" + value); } public void onStartTrackingTouch(SeekBar seekBar) {} public void onStopTrackingTouch(SeekBar seekBar) {} }); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Proposal.this); name = prefs.getString("name", null); staffkey = prefs.getString("staffkey", null); sendproposal.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { email = emailedit.getText().toString(); message = messagebox.getText().toString(); subject = proposalSubject.getText().toString(); rate = value; // sendEmail(email,"You've received a proposal from "+name+" on Staffittome!","You've // recieved a proposal from"+name+" from Staffittome! "+name+"'s additional message: // "+message); sendProposal("Java Developing", rate, email, subject, message); } }); Bundle extras = getIntent().getExtras(); String[] profinfo = extras.getStringArray("profinfo"); String[] caparray = new String[profinfo.length]; for (int i = 0; i < profinfo.length; i++) { if (profinfo[i] != null) { caparray[i] = profinfo[i]; } else { caparray[i] = ""; } } ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, caparray); capspin.setAdapter(spinnerArrayAdapter); capspin.setBackgroundColor(Color.TRANSPARENT); }