/** Initializes select contact group spinner with contact groups. */ private void initContactGroupSpinner() { Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner); MetaContactGroupAdapter contactGroupAdapter = new MetaContactGroupAdapter(this, R.id.selectGroupSpinner, true, true); contactGroupAdapter.setItemLayout(R.layout.simple_spinner_item); contactGroupAdapter.setDropDownLayout(R.layout.dropdown_spinner_item); groupSpinner.setAdapter(contactGroupAdapter); }
@Override public void onStart() { super.onStart(); if (D) Log.d(TAG, "++ ON START ++"); if (!mBluetoothAdapter.isEnabled()) { // ask the user to enable BlueTooth Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { // this only works if you already bonded with this device if (D) Log.d(TAG, "BT already enabled"); final BluetoothDevice[] bondedDevices = new BluetoothDevice[mBluetoothAdapter.getBondedDevices().size()]; mBluetoothAdapter.getBondedDevices().toArray(bondedDevices); List<CharSequence> devices = new ArrayList<CharSequence>(); // update the "Select device" spinner for (BluetoothDevice btd : bondedDevices) { Log.d(TAG, "Found bonded device: " + btd.getName()); devices.add(btd.getName()); } ArrayAdapter spinnerAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, devices); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner selectDeviceSpinner = (Spinner) findViewById(R.id.spinner); selectDeviceSpinner.setAdapter(spinnerAdapter); selectDeviceSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (D) Log.d(TAG, "Selected: " + bondedDevices[pos].getName()); btDevice = bondedDevices[pos]; } public void onNothingSelected(AdapterView<?> arg0) {} }); } }
/** Initializes "select account" spinner with existing accounts. */ private void initAccountSpinner() { Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner); Iterator<ProtocolProviderService> providers = AccountUtils.getRegisteredProviders().iterator(); List<AccountID> accounts = new ArrayList<AccountID>(); int selectedIdx = -1; int idx = 0; while (providers.hasNext()) { ProtocolProviderService provider = providers.next(); OperationSet opSet = provider.getOperationSet(OperationSetPresence.class); if (opSet == null) continue; AccountID account = provider.getAccountID(); accounts.add(account); idx++; if (account.isPreferredProvider()) { selectedIdx = idx; } } AccountsListAdapter accountsAdapter = new AccountsListAdapter( this, R.layout.select_account_row, R.layout.select_account_dropdown, accounts, true); accountsSpiner.setAdapter(accountsAdapter); // if we have only select account option and only one account // select the available account if (accounts.size() == 1) accountsSpiner.setSelection(0); else accountsSpiner.setSelection(selectedIdx); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile); findViews(); /*Select Category work */ final String[] categories = getIntent().getStringArrayExtra("Options"); ArrayAdapter<String> catadapt; catadapt = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories); mCatSpin.setAdapter(catadapt); mCatSpin.setOnItemSelectedListener( new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { mChosenCategory = categories[pos]; } public void onNothingSelected(AdapterView<?> parent) {} }); /*Availability selection work*/ mAvail = (Button) findViewById(R.id.editavail); mAvail.setOnClickListener(this); /*Submit/Back button work*/ mSub = (Button) findViewById(R.id.submitbutton); mSub.setOnClickListener(this); mBack.setOnClickListener(this); /*Web View & Camera uploader work*/ openCam.setOnClickListener(this); openWeb.setOnClickListener(this); web.getSettings().setJavaScriptEnabled(true); web.loadUrl("http://www.monkbananas.com/uploader/index.php"); // ------Everything below this line was found on StackOverflow-------------------- web.setWebChromeClient( new WebChromeClient() { @Override public boolean shouldOverrideUrlLoading(WebView v, String url) { web.loadUrl(url); return true; } // The undocumented magic method override // Eclipse will swear at you if you try to put @Override here // For Android 3.0+ public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } // For Android 4.1 public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } }); }