List of usage examples for android.widget Spinner setEnabled
@Override public void setEnabled(boolean enabled)
From source file:com.example.mediasync3.DownloadNote.java
@Override protected void onPostExecute(Boolean result) { mDialog.dismiss();/*from w w w. j ava 2 s . c o m*/ if (pos == -2) { Spinner listSpin = (Spinner) rootView.findViewById(R.id.spinner1); listSpin.setAdapter(adapterList); listSpin.setEnabled(true); } else { EditText et = (EditText) rootView.findViewById(R.id.editText1); File fl = new File(LOCAL_NOTES_DIR + "/" + fnames[pos]); et.setText(readFromFile(LOCAL_NOTES_DIR + "/" + fnames[pos])); /* ListView lv = (ListView)rootView.findViewById(R.id.listView1); ArrayList<String> dir=new ArrayList<String>(); //File sdCardRoot = Environment.getExternalStorageDirectory(); final File MusicDir = new File(LOCAL_NOTES_DIR); for (File f : MusicDir.listFiles()) { if (f.isFile()) dir.add(f.getName()); // Do your stuff } String[] localnames = dir.toArray(new String[dir.size()]); ArrayAdapter<String> ad = new ArrayAdapter<String>(mFrag.getActivity(), android.R.layout.simple_list_item_1,localnames); lv.setAdapter(ad); //TextView tv = (TextView) rootView.findViewById(R.id.textView1); //tv.setText(fnames[pos]); */ } if (result) { // Set the image now that we have it // mView.setImageDrawable(mDrawable); } else { // Couldn't download it, so show an error // showToast(mErrorMsg); } }
From source file:com.vuze.android.remote.activity.DrawerActivity.java
private void setupProfileSpinner() { Spinner spinner = (Spinner) findViewById(R.id.drawer_profile_spinner); if (spinner == null) { return;/*from w w w. ja v a 2 s. co m*/ } AppPreferences appPreferences = VuzeRemoteApp.getAppPreferences(); if (appPreferences.getNumRemotes() <= 1) { spinner.setEnabled(false); } RemoteProfile remoteProfile = getSessionInfo().getRemoteProfile(); final ActionBarArrayAdapter adapter = new ActionBarArrayAdapter(this); final int initialPos = adapter.refreshList(remoteProfile); // Note: If the adapter returns itemPosition for itemID, we have problems // when the user rotates the screen (something about restoring the drop // down list, firing the wrong id/position) // Most "solutions" on the internet say "ignore first call too onNavigationItemSelected" // but I've found this not to be consistent (in some cases there is no phantom // call) OnItemSelectedListener navigationListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int itemPosition, long itemId) { RemoteProfile remoteProfile = getSessionInfo().getRemoteProfile(); RemoteProfile profile = adapter.getItem(itemPosition); if (profile != null && !profile.getID().equals(remoteProfile.getID())) { if (DEBUG_SPINNER) { Log.d(TAG, remoteProfile.getNick() + "] Spinner Selected " + itemPosition + ":" + itemId + "/" + profile.getNick() + " via " + AndroidUtils.getCompressedStackTrace()); } finish(); RemoteUtils.openRemote(DrawerActivity.this, profile, false); return; } if (DEBUG_SPINNER) { Log.d(TAG, remoteProfile.getNick() + "] Spinner Selected " + itemPosition + ":" + itemId + "/" + (profile == null ? "null" : profile.getNick()) + " ignored"); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }; spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(navigationListener); if (DEBUG_SPINNER) { Log.d(TAG, remoteProfile.getNick() + "] Spinner seting pos to " + initialPos); } // This doesn't seem to trigger naviationListener spinner.setSelection(initialPos); if (DEBUG_SPINNER) { Log.d(TAG, remoteProfile.getNick() + "] Spinner set pos to " + initialPos); } }
From source file:org.catrobat.catroid.content.bricks.BroadcastBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }/*from ww w . j a v a 2s . co m*/ if (view == null) { alphaValue = 255; } view = View.inflate(context, R.layout.brick_broadcast, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_broadcast_checkbox); checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(BroadcastBrick.this, isChecked); } }); final Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context)); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedMessage = broadcastSpinner.getSelectedItem().toString(); if (selectedMessage.equals(context.getString(R.string.new_broadcast_message))) { showNewMessageDialog(broadcastSpinner); } else { broadcastMessage = selectedMessage; adapterView = parent; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); setSpinnerSelection(broadcastSpinner); return view; }
From source file:org.catrobat.catroid.content.bricks.BroadcastReceiverBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }//ww w.j a v a 2 s . com if (view == null) { alphaValue = 255; } if (receiveScript == null) { receiveScript = new BroadcastScript(broadcastMessage); MessageContainer.addMessage(getBroadcastMessage()); } view = View.inflate(context, R.layout.brick_broadcast_receive, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_broadcast_receive_checkbox); // XXX method moved to to DragAndDropListView since it is not working on 2.x // checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { // // @Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // checked = isChecked; // if (!checked) { // for (Brick currentBrick : adapter.getCheckedBricks()) { // currentBrick.setCheckedBoolean(false); // } // } // adapter.handleCheck(brickInstance, checked); // } // }); final Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_receive_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context)); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedMessage = broadcastSpinner.getSelectedItem().toString(); if (selectedMessage.equals(context.getString(R.string.new_broadcast_message))) { showNewMessageDialog(broadcastSpinner); } else { receiveScript.setBroadcastMessage(selectedMessage); broadcastMessage = selectedMessage; } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); setSpinnerSelection(broadcastSpinner); return view; }
From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java
private void configureProjectSpinner(View view) { final Spinner projectSpinner = (Spinner) view.findViewById(R.id.spinner_hours_detail_project); projectSpinner.setEnabled(isThisHoursRecordNotActive()); if (isThisHoursRecordActive()) { projectSpinner.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.no_border, null)); } else {/* w w w . jav a2s. c o m*/ projectSpinner .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_border, null)); } projectSpinner.setAdapter(new AbstractArrayAdapter(getActivity(), R.layout.project_list_row) { @Override protected ViewBinder<Project> createViewBinder() { return new ProjectViewBinder(); } }); projectSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Project project = (Project) projectSpinner.getAdapter().getItem(position); if (project == Project.MANAGE_PROJECTS) { // Launch the Project List Screen Intent intent = new Intent(getActivity(), ProjectListActivity.class); intent.putExtra(ProjectListActivity.EXTRA_JOB, mHours.getJob()); //Toast.makeText(getActivity(), "Launching ProjectListActivity (eventually)...", Toast.LENGTH_LONG).show(); startActivityForResult(intent, REQUEST_CODE_MANAGE_PROJECTS); } else { // Active project has changed. Update the UI. mHours.setProject(project); updateUI(); } } @Override public void onNothingSelected(AdapterView<?> parent) { // Nothing to do } }); }
From source file:li.klass.fhem.fragments.ConnectionDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { return view; }/*from www .ja v a2 s . co m*/ view = inflater.inflate(R.layout.connection_detail, container, false); assert (view != null); Spinner connectionTypeSpinner = (Spinner) view.findViewById(R.id.connectionType); if (isModify) { connectionTypeSpinner.setEnabled(false); } final List<ServerType> connectionTypes = getServerTypes(); ArrayAdapter<ServerType> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, connectionTypes); connectionTypeSpinner.setAdapter(adapter); connectionTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { handleConnectionTypeChange(connectionTypes.get(position)); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); Button saveButton = (Button) view.findViewById(R.id.save); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handleSave(); } }); return view; }
From source file:hku.fyp14017.blencode.content.bricks.BroadcastBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }/*from w w w .ja va 2 s . com*/ if (view == null) { alphaValue = 255; } view = View.inflate(context, hku.fyp14017.blencode.R.layout.brick_broadcast, null); view = getViewWithAlpha(alphaValue); setCheckboxView(hku.fyp14017.blencode.R.id.brick_broadcast_checkbox); checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(BroadcastBrick.this, isChecked); } }); final Spinner broadcastSpinner = (Spinner) view .findViewById(hku.fyp14017.blencode.R.id.brick_broadcast_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context)); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedMessage = broadcastSpinner.getSelectedItem().toString(); if (selectedMessage .equals(context.getString(hku.fyp14017.blencode.R.string.new_broadcast_message))) { showNewMessageDialog(broadcastSpinner); } else { broadcastMessage = selectedMessage; adapterView = parent; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); setSpinnerSelection(broadcastSpinner); return view; }
From source file:hku.fyp14017.blencode.content.bricks.BroadcastReceiverBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }/* w ww. j a v a 2 s .co m*/ if (view == null) { alphaValue = 255; } if (receiveScript == null) { receiveScript = new BroadcastScript(broadcastMessage); MessageContainer.addMessage(getBroadcastMessage()); } view = View.inflate(context, hku.fyp14017.blencode.R.layout.brick_broadcast_receive, null); view = getViewWithAlpha(alphaValue); setCheckboxView(hku.fyp14017.blencode.R.id.brick_broadcast_receive_checkbox); // XXX method moved to to DragAndDropListView since it is not working on 2.x // checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { // // @Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // checked = isChecked; // if (!checked) { // for (Brick currentBrick : adapter.getCheckedBricks()) { // currentBrick.setCheckedBoolean(false); // } // } // adapter.handleCheck(brickInstance, checked); // } // }); final Spinner broadcastSpinner = (Spinner) view .findViewById(hku.fyp14017.blencode.R.id.brick_broadcast_receive_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context)); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedMessage = broadcastSpinner.getSelectedItem().toString(); if (selectedMessage .equals(context.getString(hku.fyp14017.blencode.R.string.new_broadcast_message))) { showNewMessageDialog(broadcastSpinner); } else { receiveScript.setBroadcastMessage(selectedMessage); broadcastMessage = selectedMessage; } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); setSpinnerSelection(broadcastSpinner); return view; }
From source file:com.xperia64.timidityae.TrackFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { reset();/*from w w w . j ava2 s . c o m*/ fileList = new ArrayAdapter<String>(getActivity(), R.layout.row); for (int i = 0; i < JNIHandler.MAX_CHANNELS; i++) { fileList.add(String.format(getActivity().getResources().getString(R.string.trk_form), (getActivity().getResources() .getString(JNIHandler.drums.get(i) ? R.string.trk_drum : R.string.trk_inst2)), (i + 1), JNIHandler.drums.get(i) ? 0 : localInst.get(i) + 1, localVol.get(i))); } channelList.setAdapter(fileList); channelList.setOnItemClickListener(new OnItemClickListener() { @SuppressLint("InflateParams") @Override public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); View v = getActivity().getLayoutInflater().inflate(R.layout.track_dialog, null); final Spinner instSpin = (Spinner) v.findViewById(R.id.instSpin); instSpin.setClickable(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2)); instSpin.setOnLongClickListener(null); instSpin.setEnabled(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2)); List<String> arrayAdapter = new ArrayList<String>(); final int offset = (!JNIHandler.drums.get(arg2)) ? 0 : 34; if (!JNIHandler.drums.get(arg2)) { for (String inst : getActivity().getResources().getStringArray(R.array.midi_instruments)) arrayAdapter.add(inst); } else { for (String inst : getActivity().getResources().getStringArray(R.array.midi_drums)) arrayAdapter.add(inst); } ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arrayAdapter); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item); } else { dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } dataAdapter.setNotifyOnChange(false); if (!JNIHandler.drums.get(arg2)) { instSpin.setAdapter(dataAdapter); instSpin.setSelection(localInst.get(arg2) - offset); } final EditText txtVol = (EditText) v.findViewById(R.id.txtVol); txtVol.setText(Integer.toString(localVol.get(arg2))); txtVol.setClickable(JNIHandler.custVol.get(arg2)); txtVol.setEnabled(JNIHandler.custVol.get(arg2)); final SeekBar volSeek = (SeekBar) v.findViewById(R.id.volSeek); volSeek.setClickable(JNIHandler.custVol.get(arg2)); volSeek.setEnabled(JNIHandler.custVol.get(arg2)); volSeek.setMax(127); volSeek.setProgress(localVol.get(arg2)); volSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) { if (arg2 && !fromUser) { fromUser = true; txtVol.setText(Integer.toString(arg0.getProgress())); } else { fromUser = false; } } @Override public void onStartTrackingTouch(SeekBar arg0) { } @Override public void onStopTrackingTouch(SeekBar arg0) { } }); txtVol.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { if (!fromUser) { if (s.length() > 0) { int numm = Integer.parseInt(s.toString()); if (numm > 127) { fromUser = true; numm = 127; } if (numm < 0) { fromUser = true; numm = 0; } if (fromUser) { txtVol.setText(Integer.toString(numm)); } fromUser = true; volSeek.setProgress(numm); fromUser = false; } } else { fromUser = false; } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final CheckBox inst = (CheckBox) v.findViewById(R.id.defInstr); inst.setEnabled(!JNIHandler.drums.get(arg2)); inst.setChecked(!JNIHandler.custInst.get(arg2)); inst.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { instSpin.setClickable(!arg1); instSpin.setEnabled(!arg1); } }); final CheckBox vol = (CheckBox) v.findViewById(R.id.defVol); vol.setChecked(!JNIHandler.custVol.get(arg2)); //System.out.println("Def inst: "+(!JNIHandler.custInst.get(arg2)?"true":"false")+" def vol: "+(!JNIHandler.custVol.get(arg2)?"true":"false")); vol.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { volSeek.setClickable(!arg1); volSeek.setEnabled(!arg1); txtVol.setClickable(!arg1); txtVol.setEnabled(!arg1); } }); if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK); b.setView(v); b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { JNIHandler.custInst.set(arg2, !inst.isChecked()); JNIHandler.custVol.set(arg2, !vol.isChecked()); JNIHandler.setChannelVolumeTimidity(arg2 | (JNIHandler.custVol.get(arg2) ? 0x800 : 0x8000), volSeek.getProgress()); JNIHandler.setChannelTimidity(arg2 | (JNIHandler.custInst.get(arg2) ? 0x800 : 0x8000), instSpin.getSelectedItemPosition()); if (!JNIHandler.paused && Globals.isPlaying == 0) JNIHandler.seekTo(JNIHandler.currTime); //bigCounter=12; updateList(); } }); b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); b.setTitle(String.format((getActivity().getResources().getString(R.string.trk_form2)), (arg2 + 1))); ddd = b.create(); ddd.show(); } }); }
From source file:org.catrobat.catroid.content.bricks.BroadcastWaitBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }//from ww w. ja v a 2 s . com view = View.inflate(context, R.layout.brick_broadcast_wait, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_broadcast_wait_checkbox); final Brick brickInstance = this; checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(brickInstance, isChecked); } }); final Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_wait_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } final ArrayAdapter<String> spinnerAdapter = MessageContainer.getMessageAdapter(context); SpinnerAdapterWrapper spinnerAdapterWrapper = new SpinnerAdapterWrapper(context, broadcastSpinner, spinnerAdapter); broadcastSpinner.setAdapter(spinnerAdapterWrapper); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { private boolean start = true; @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (start) { start = false; return; } broadcastMessage = ((String) parent.getItemAtPosition(pos)).trim(); if (broadcastMessage == context.getString(R.string.new_broadcast_message)) { broadcastMessage = ""; } else { oldMessage = broadcastMessage; } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); setSpinnerSelection(broadcastSpinner); return view; }