Java Code Examples for android.widget.Spinner

The following examples show how to use android.widget.Spinner. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void initializeSpinner(Spinner countrySpinner) {
  countrySpinnerAdapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_spinner_item);
  countrySpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

  setCountryDisplay(getString(R.string.RegistrationActivity_select_your_country));

  countrySpinner.setAdapter(countrySpinnerAdapter);
  countrySpinner.setOnTouchListener((view, event) -> {
    if (event.getAction() == MotionEvent.ACTION_UP) {
      pickCountry(view);
    }
    return true;
  });
  countrySpinner.setOnKeyListener((view, keyCode, event) -> {
    if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && event.getAction() == KeyEvent.ACTION_UP) {
      pickCountry(view);
      return true;
    }
    return false;
  });
}
 
Example 2
public StatisticsCache(AppCompatActivity activity)
{
    this.activity = activity;

    titleTextView = (TextView) activity.findViewById(R.id.textview_stats_title);
    chart = (BarChart) activity.findViewById(R.id.chart);
    totalTextView = (TextView) activity.findViewById(R.id.textview_stats_total);

    unitsTextView = (TextView) activity.findViewById(R.id.textview_stats_currency);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    String defaultCurrency = activity.getResources().getString(R.string.currency);
    currency = prefs.getString(SettingsKeys.CURRENCY, defaultCurrency);
    unitsTextView.setText(currency);

    rangeFromTextView = (TextView) activity.findViewById(R.id.textview_stats_range_from);
    rangeToTextView = (TextView) activity.findViewById(R.id.textview_stats_range_to);
    groupBySpinner = (Spinner) activity.findViewById(R.id.spinner_stats_group_by);
    valuesSpinner = (Spinner) activity.findViewById(R.id.spinner_stats_values);

    datePattern = activity.getResources().getString(R.string.date_short_pattern);
    dateLanguage = activity.getResources().getString(R.string.language);
    numberFormat = activity.getResources().getString(R.string.number_format_2_decimals);
}
 
Example 3
Source Project: Dashchan   Source File: DropdownView.java    License: Apache License 2.0 6 votes vote down vote up
public DropdownView(Context context, AttributeSet attrs) {
	super(context, attrs);
	spinner = new Spinner(context);
	spinner.setId(android.R.id.edit);
	spinner.setPadding(0, 0, 0, 0);
	addView(spinner, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	LayoutParams layoutParams = (LayoutParams) spinner.getLayoutParams();
	if (C.API_LOLLIPOP) {
		layoutParams.gravity = Gravity.CENTER_VERTICAL;
		setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.editTextBackground, 0));
		setAddStatesFromChildren(true);
	} else {
		float density = ResourceUtils.obtainDensity(context);
		layoutParams.setMargins(0, (int) (4f * density), 0, (int) (4f * density));
	}
}
 
Example 4
Source Project: BotLibre   Source File: TrainingActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void browse() {
	ResponseConfig response = getSelectedResponse();
	if (response == null) {
		MainActivity.error("Select a response browse", null, this);
       	return;
	}
	ResponseSearchConfig config = new ResponseSearchConfig();
	config.instance = this.instance.id;
	config.responseType = "responses";
	config.duration = "all";
	config.inputType = "all";
	config.restrict = "exact";
	config.filter = response.response;

	this.first = true;
	Spinner spin = (Spinner) findViewById(R.id.responseTypeSpin);
	spin.setSelection(Arrays.asList(MainActivity.responseTypes).indexOf("responses"));
	this.responses = new ArrayList<ResponseConfig>();
	
    HttpAction action = new HttpGetResponsesAction(this, config);
	action.execute();
}
 
Example 5
private void initVideoQualityPanel(final View root) {
    final Spinner presetSpinner = (Spinner) root.findViewById(R.id.video_quality_presets);
    ArrayAdapter<String> data = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, VIDEO_QUALITY_PRESETS);
    presetSpinner.setAdapter(data);
    presetSpinner.setSelection(4);

    Spinner profileSpinner = (Spinner) root.findViewById(R.id.video_quality_custom_profile);
    data = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, VIDEO_QUALITY_PROFILES);
    profileSpinner.setAdapter(data);
    profileSpinner.setSelection(0);

    RadioGroup videoRadioGroup = (RadioGroup) root.findViewById(R.id.video_quality_radio_group);
    videoRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            View customPanel = root.findViewById(R.id.video_quality_custom_panel);
            presetSpinner.setVisibility(checkedId == R.id.video_quality_preset ? View.VISIBLE : View.GONE);
            customPanel.setVisibility(checkedId == R.id.video_quality_preset ? View.GONE : View.VISIBLE);
        }
    });
}
 
Example 6
@Override
protected View getInputView() {
    Spinner spinScaleUer = new Spinner(getContext());
    ArrayAdapter<String> spinScaleUserAdapter = new ArrayAdapter<>(getContext(), R.layout.support_simple_spinner_dropdown_item, new ArrayList<>());

    spinScaleUer.setAdapter(spinScaleUserAdapter);

    int spinPos = 0;

    for (ScaleUser scaleUser : openScale.getScaleUserList()) {
        spinScaleUserAdapter.add(scaleUser.getUserName());

        if (scaleUser.getId() == userId) {
            spinPos = spinScaleUserAdapter.getCount() - 1;
        }
    }

    spinScaleUer.setSelection(spinPos);

    return spinScaleUer;
}
 
Example 7
Source Project: FTCLibrary   Source File: SingleSelectCategory.java    License: MIT License 6 votes vote down vote up
/**
 * @inheritDoc Constructs an Spinner object, using an ArrayAdapter to set the spinner options
 * provided
 */
@Override
public View getView(Context context) {
    //Generate ID
    id = ID_OFFSET + new Random().nextInt(100);
    //Create row
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout row = new LinearLayout(context);
    row.setOrientation(LinearLayout.HORIZONTAL);
    //Create TextView
    TextView t = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, null);
    t.setText(name);
    row.addView(t);
    //Create Spinner
    Spinner spinner = new Spinner(context);
    spinner.setId(id);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
            android.R.layout.simple_spinner_dropdown_item, options);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    row.addView(spinner);
    view = row;
    return row;
}
 
Example 8
@Override
public View getChildView(final int groupPosition, final int childPosition, final boolean isLastChild,
        View convertView, final ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.keybinding_action, parent, false);
    }

    final KeyAction action = getChild(groupPosition, childPosition);

    final TextView keyView = (TextView) convertView.findViewById(R.id.keybinding_key);
    keyView.setText(action.label);

    final Spinner actionsView = (Spinner) convertView.findViewById(R.id.keybinding_actions);
    actionsView.setOnItemSelectedListener(this);
    actionsView.setAdapter(actionsAdapter);
    actionsView.setTag(action);
    updateAction(actionsView);

    return convertView;
}
 
Example 9
Source Project: grafika   Source File: PlayMovieActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_movie);

    mTextureView = (TextureView) findViewById(R.id.movie_texture_view);
    mTextureView.setSurfaceTextureListener(this);

    // Populate file-selection spinner.
    Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
    // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
    // for the widget itself.
    mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, mMovieFiles);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner.
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    updateControls();
}
 
Example 10
Source Project: UltimateAndroid   Source File: ConfigureStandupTimer.java    License: Apache License 2.0 6 votes vote down vote up
public void onClick(View v) {
    Intent i = new Intent(this, StandupTimer.class);

    meetingLength = getMeetingLengthFromUI();
    i.putExtra("meetingLength", meetingLength);

    TextView t = (TextView) findViewById(R.id.num_participants);
    numParticipants = parseNumberOfParticipants(t);
    i.putExtra("numParticipants", numParticipants);

    Spinner teamNameSpinner = (Spinner) findViewById(R.id.team_names);
    teamNamesPos = teamNameSpinner.getSelectedItemPosition();
    i.putExtra("teamName", (String) teamNameSpinner.getSelectedItem());

    if (numParticipants < 1 || (Prefs.allowUnlimitedParticipants(this) == false && numParticipants > 20)) {
        showInvalidNumberOfParticipantsDialog();
    } else {
        saveState();
        startTimer(i);
    }
}
 
Example 11
Source Project: accountBook   Source File: CountActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化spinner
 */
private void initSpinner(){
    month_spinner = (Spinner) findViewById(R.id.month_spinner);
    //将可选内容与ArrayAdapter连接起来
    month_adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, monthList);
    //设置下拉列表的风格
    month_adapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //将adapter添加到spinner中
    month_spinner.setAdapter(month_adapter);
    //添加事件Spinner事件监听
    month_spinner
            .setOnItemSelectedListener(new month_spinnerSelectedListener());
    //设置默认值
    month_spinner.setSelection(pubFun.getTime("M"), true);
    month_spinner.setVisibility(View.VISIBLE);
}
 
Example 12
Source Project: DroneKit-Android-Starter   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
public void onBtnConnectTap(View view) {
    if (this.drone.isConnected()) {
        this.drone.disconnect();
    } else {
        Spinner connectionSelector = (Spinner) findViewById(R.id.selectConnectionType);
        int selectedConnectionType = connectionSelector.getSelectedItemPosition();

        Bundle extraParams = new Bundle();
        if (selectedConnectionType == ConnectionType.TYPE_USB) {
            extraParams.putInt(ConnectionType.EXTRA_USB_BAUD_RATE, DEFAULT_USB_BAUD_RATE); // Set default baud rate to 57600
        } else {
            extraParams.putInt(ConnectionType.EXTRA_UDP_SERVER_PORT, DEFAULT_UDP_PORT); // Set default baud rate to 14550
        }

        ConnectionParameter connectionParams = new ConnectionParameter(selectedConnectionType, extraParams, null);
        this.drone.connect(connectionParams);
    }

}
 
Example 13
Source Project: styT   Source File: AddressToPostcodeActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_postcode_a2p);
	spProvince = (Spinner) findViewById(R.id.spProvince);
	spProvince.setOnItemSelectedListener(this);
	spCity = (Spinner) findViewById(R.id.spCity);
	spCity.setOnItemSelectedListener(this);
	spDistrict = (Spinner) findViewById(R.id.spDistrict);
	spDistrict.setOnItemSelectedListener(this);
	spAddress = (Spinner) findViewById(R.id.spAddress);
	spAddress.setOnItemSelectedListener(this);
	tvPostcode = (TextView) findViewById(R.id.tvPostcode);

	// 获取API,请求城市列表
	Postcode api = (Postcode) MobAPI.getAPI(Postcode.NAME);
	api.listAddress(this);
}
 
Example 14
Source Project: Atomic   Source File: AddServerActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate a server object from the data in the view
 *
 * @return The server object
 */
private Server getServerFromView() {
  String title = ((EditText)findViewById(R.id.title)).getText().toString().trim();
  String host = ((EditText)findViewById(R.id.host)).getText().toString().trim();
  int port = Integer.parseInt(((EditText)findViewById(R.id.port)).getText().toString().trim());
  String password = ((EditText)findViewById(R.id.password)).getText().toString().trim();
  String charset = ((Spinner)findViewById(R.id.charset)).getSelectedItem().toString();
  Boolean useSSL = ((CheckBox)findViewById(R.id.useSSL)).isChecked();
  Boolean autoConnect = ((CheckBox)findViewById(R.id.autoconnect)).isChecked();

  Server server = new Server();
  server.setHost(host);
  server.setPort(port);
  server.setPassword(password);
  server.setTitle(title);
  server.setCharset(charset);
  server.setUseSSL(useSSL);
  server.setAutoconnect(autoConnect);
  server.setStatus(Status.DISCONNECTED);

  return server;
}
 
Example 15
Source Project: aedict   Source File: MainActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
	final Activity activity = MainActivity.this;
	final Spinner matcher = (Spinner) activity.findViewById(R.id.matcher);
	final CheckBox deinflect = (CheckBox) activity.findViewById(R.id.jpDeinflectVerbs);
	final CheckBox tanaka = (CheckBox) activity.findViewById(R.id.searchExamples);
	final CheckBox translate = (CheckBox) activity.findViewById(R.id.translate);
	if (buttonView.getId() == R.id.jpDeinflectVerbs && isChecked) {
		matcher.setSelection(MatcherEnum.Exact.ordinal());
		tanaka.setChecked(false);
		translate.setChecked(false);
	} else if (buttonView.getId() == R.id.searchExamples && isChecked) {
		matcher.setSelection(MatcherEnum.Substring.ordinal());
		deinflect.setChecked(false);
		translate.setChecked(false);
	} else if (buttonView.getId() == R.id.translate && isChecked) {
		deinflect.setChecked(false);
		tanaka.setChecked(false);
	}
	matcher.setEnabled(!deinflect.isChecked() && !tanaka.isChecked() && !translate.isChecked());
	findViewById(R.id.englishSearch).setEnabled(!translate.isChecked() && !deinflect.isChecked());
}
 
Example 16
Source Project: KinoCast   Source File: DetailActivity.java    License: MIT License 6 votes vote down vote up
private void setMirrorSpinner(Host mirrors[]) {
    if (mirrors != null && mirrors.length > 0) {
        Arrays.sort(mirrors, new WeightedHostComparator(Utils.getWeightedHostList(getApplicationContext())));
        ((Spinner) findViewById(R.id.spinnerMirror)).setAdapter(
                new ArrayAdapter<>(DetailActivity.this, android.R.layout.simple_list_item_1,
                        mirrors));
        findViewById(R.id.spinnerMirror).setEnabled(true);
        findViewById(R.id.buttonPlay).setEnabled(true);
    } else {
        ((Spinner) findViewById(R.id.spinnerMirror)).setAdapter(
                new ArrayAdapter<>(DetailActivity.this, android.R.layout.simple_list_item_1,
                        new String[]{getString(R.string.no_host_found)}));
        findViewById(R.id.spinnerMirror).setEnabled(false);
        findViewById(R.id.buttonPlay).setEnabled(false);
    }
    findViewById(R.id.layoutMirror).setVisibility(View.VISIBLE);
}
 
Example 17
Source Project: api-samples   Source File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate (Bundle savedInstanceState)
{
    super.onCreate( savedInstanceState );

    setContentView(R.layout.demo);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    in_call = false;
    room_edit = ( EditText )findViewById( R.id.room_name );
    join_button = ( Button )findViewById( R.id.join_button );
    status = ( TextView )findViewById( R.id.status );
    loader_spinner = ( ImageView )findViewById( R.id.loader_spinner );
    call_layout = ( MediaStreamLayout )findViewById( R.id.call_layout );
    room_edit.setText(DEFAULT_ROOM_NAME);
    room_layout = ( LinearLayout )findViewById( R.id.room_layout );
    orientation_landscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
    if ( orientation_landscape ) {
        room_layout.setOrientation(LinearLayout.HORIZONTAL);
    } else {
        room_layout.setOrientation(LinearLayout.VERTICAL);
    }
    select_camera = ( Spinner )findViewById( R.id.select_camera );

    // Conference
    conference = Conference.getInstance( getApplicationContext() );
    conference.setInfo( "38077edb", "4f304359baa6d0fd1f9106aaeb116f33" );

    conference.setVideoOption( VideoOption.MAX_WIDTH, 320 );
    conference.setVideoOption( VideoOption.MAX_HEIGHT, 240 );
    conference.setVideoOption( VideoOption.MAX_FRAME_RATE, 15 );

    conference.setAudioOption( AudioOption.PREFERRED_CODEC, AudioCodec.ISAC );
    conference.setAudioOption( AudioOption.PREFERRED_CODEC_CLOCKRATE, 16000 );
    conference.setLoudspeaker( false );
    init();
}
 
Example 18
Source Project: Field-Book   Source File: SearchActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void addRow(String text) {
    LayoutInflater vi = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = vi.inflate(R.layout.listitem_search_constructor, null);

    Spinner c = v.findViewById(R.id.columns);
    Spinner s = v.findViewById(R.id.like);
    EditText e = v.findViewById(R.id.searchText);

    String[] likes = new String[6];

    likes[0] = getString(R.string.search_dialog_query_is_equal_to);
    likes[1] = getString(R.string.search_dialog_query_is_not_equal_to);
    likes[2] = getString(R.string.search_dialog_query_contains);
    likes[3] = getString(R.string.search_dialog_query_does_not_contain);
    likes[4] = getString(R.string.search_dialog_query_is_more_than);
    likes[5] = getString(R.string.search_dialog_query_is_less_than);

    ArrayAdapter adapter = new ArrayAdapter(SearchActivity.this, R.layout.custom_spinnerlayout, likes);
    //adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s.setAdapter(adapter);

    String[] col = ConfigActivity.dt.getRangeColumns();

    if (col != null) {
        rangeUntil = col.length;

        ArrayAdapter adapter2 = new ArrayAdapter(SearchActivity.this, R.layout.custom_spinnerlayout,
                concat(col, ConfigActivity.dt.getVisibleTrait()));
        adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        c.setAdapter(adapter2);

        if (text.length() > 0)
            e.setText(text);

        parent.addView(v);
    }
}
 
Example 19
Source Project: memoir   Source File: HorizontalRTToolbar.java    License: Apache License 2.0 5 votes vote down vote up
private void setFontColor(int color, Spinner spinner, SpinnerItemAdapter<? extends ColorSpinnerItem> adapter) {
    int color2Compare = color & 0xffffff;
    for (int pos = 0; pos < adapter.getCount(); pos++) {
        ColorSpinnerItem item = adapter.getItem(pos);
        if (!item.isEmpty() && color2Compare == (item.getColor() & 0xffffff)) {
            adapter.setSelectedItem(pos);
            spinner.setSelection(pos);
            break;
        }
    }
}
 
Example 20
private void selectSpinnerValue(Spinner spinner, String value) {
    for (int i = 0; i < spinner.getCount(); i++) {
        if (spinner.getItemAtPosition(i).toString().equals(value)) {
            spinner.setSelection(i);
            break;
        }
    }
}
 
Example 21
Source Project: fresco   Source File: BitmapAnimationDebugFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

  // Get the animation container
  final ImageView imageView = (ImageView) view.findViewById(R.id.animation_container);

  mFrameInformationContainer = (LinearLayout) view.findViewById(R.id.frame_information);

  mAnimatedDrawable = new AnimatedDrawable2();
  mAnimatedDrawable.setDrawListener(new AnimatedDrawable2DebugDrawListener());

  view.findViewById(R.id.invalidate_button)
      .setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              imageView.invalidate();
            }
          });

  mAnimationControlsManager =
      new AnimationControlsManager(
          mAnimatedDrawable,
          (SeekBar) getView().findViewById(R.id.seekbar),
          (ToggleButton) getView().findViewById(R.id.playpause),
          getView().findViewById(R.id.reset));

  new BitmapAnimationCacheSelectorConfigurator(
      (Spinner) view.findViewById(R.id.spinner),
      mBitmapFrameCacheChangedListener,
      mFrameCacheListener);

  imageView.setImageDrawable(mAnimatedDrawable);
}
 
Example 22
private boolean onLimitsPreferenceClicked(final Preference preference) {
    final View v = UI.inflateDialog(getActivity(), R.layout.dialog_set_limits);
    final Spinner currencySpinner = UI.find(v, R.id.set_limits_currency);
    final EditText amountEdit = UI.find(v, R.id.set_limits_amount);

    final String[] currencies;
    if (mService.isElements())
        currencies = new String[]{mService.getAssetSymbol()};
    else if (!mService.hasFiatRate())
        currencies = new String[]{"BTC"};
    else
        currencies = new String[]{"BTC", mService.getFiatCurrency()};

    final ArrayAdapter<String> adapter;
    adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, currencies);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    currencySpinner.setAdapter(adapter);
    if (currencies.length > 1 && mService.getSpendingLimits().getBool("is_fiat"))
        currencySpinner.setSelection(1);

    final MaterialDialog dialog;
    dialog = UI.popup(getActivity(), R.string.twoFacLimitTitle)
               .customView(v, true)
               .onPositive(new MaterialDialog.SingleButtonCallback() {
                   @Override
                   public void onClick(final MaterialDialog dlg, final DialogAction which) {
                       try {
                           final String currency = currencySpinner.getSelectedItem().toString();
                           final String amount = UI.getText(amountEdit);
                           final boolean isFiat = !currency.equals(currencies[0]);
                           onNewLimitsSelected(TextUtils.isEmpty(amount) ? "0" : amount, isFiat);
                       } catch (final Exception e) {
                           UI.toast(getActivity(), "Error setting limits", Toast.LENGTH_LONG);
                       }
                   }
               }).build();
    UI.showDialog(dialog);
    return false;
}
 
Example 23
Source Project: octodroid   Source File: main_card.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(String[][] strings) {
    try {
        if (strings[0][0].contains("null")) {
            final Button right = (Button) rootView.findViewById(R.id.buttonConDis);
            right.setText("Connect");
            right.setEnabled(false);
            return;
        }
    }catch (Exception e){

    }
    ArrayList<String> spinnerArray = new ArrayList<String>();
    for (String i : strings[0]){
        spinnerArray.add(i.replace("\\/", "/"));
    }
    ArrayList<String> spinnerArray2 = new ArrayList<String>();
    for (String i2 : strings[1]){
        spinnerArray2.add(i2);
    }
    LinearLayout layout = new LinearLayout(rootView.getContext());
    final Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, spinnerArray);
    spinner.setAdapter(spinnerArrayAdapter);
    spinner.setEnabled(true);

    final Spinner spinner2 = (Spinner) rootView.findViewById(R.id.spinner2);
    ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, spinnerArray2);
    spinner2.setAdapter(spinnerArrayAdapter2);
    spinner2.setEnabled(true);


}
 
Example 24
private void setWeakReferences() {
    emptyTextViewWeakReference = new WeakReference<TextView>(emptyTextView);
    sendButtonWeakReference = new WeakReference<ImageButton>(sendButton);
    messageEditTextWeakReference = new WeakReference<EditText>(messageEditText);
    swipeLayoutWeakReference = new WeakReference<SwipeRefreshLayout>(swipeLayout);
    layoutManagerWeakReference = new WeakReference<LinearLayoutManager>(linearLayoutManager);
    contextSpinnerWeakReference = new WeakReference<Spinner>(contextSpinner);
    contextFrameLayoutWeakReference = new WeakReference<FrameLayout>(contextFrameLayout);
}
 
Example 25
Source Project: walt   Source File: ScreenResponseFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
    shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_blink_histogram, true);
    enableFullScreen = getBooleanPreference(getContext(), R.string.preference_screen_fullscreen, true);
    if (getBooleanPreference(getContext(), R.string.preference_systrace, true)) {
        traceLogger = TraceLogger.getInstance();
    }
    waltDevice = WaltDevice.getInstance(getContext());
    logger = SimpleLogger.getInstance(getContext());

    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.fragment_screen_response, container, false);
    stopButton = view.findViewById(R.id.button_stop_screen_response);
    startButton = view.findViewById(R.id.button_start_screen_response);
    blackBox = (TextView) view.findViewById(R.id.txt_black_box_screen);
    fastSurfaceView = (FastPathSurfaceView) view.findViewById(R.id.fast_path_surface);
    spinner = (Spinner) view.findViewById(R.id.spinner_screen_response);
    buttonBarView = view.findViewById(R.id.button_bar);
    ArrayAdapter<CharSequence> modeAdapter = ArrayAdapter.createFromResource(getContext(),
            R.array.screen_response_mode_array, android.R.layout.simple_spinner_item);
    modeAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    spinner.setAdapter(modeAdapter);
    stopButton.setEnabled(false);
    blackBox.setMovementMethod(new ScrollingMovementMethod());
    brightnessChartLayout = view.findViewById(R.id.brightness_chart_layout);
    view.findViewById(R.id.button_close_chart).setOnClickListener(this);
    brightnessChart = (LineChart) view.findViewById(R.id.chart);
    latencyChart = (HistogramChart) view.findViewById(R.id.latency_chart);

    if (getBooleanPreference(getContext(), R.string.preference_auto_increase_brightness, true)) {
        increaseScreenBrightness();
    }
    return view;
}
 
Example 26
Source Project: CameraV   Source File: GalleryFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	super.onCreateOptionsMenu(menu, inflater);
	inflater.inflate(R.menu.activity_home_gallery, menu);

	MenuItem menuFilter = menu.findItem(R.id.menu_filter);
	Spinner spinner = (Spinner) menuFilter.getActionView();
	GalleryFilterAdapter spinnerAdapter = new GalleryFilterAdapter(spinner.getContext(), this.getResources().getTextArray(R.array.filter_options));
	spinner.setAdapter(spinnerAdapter);
	spinner.setOnItemSelectedListener(this);
	
	mMenuItemBatchOperations = menu.findItem(R.id.menu_select);
	
	miDropbox = menu.findItem(R.id.menu_remote_access_dropbox);
	DropboxSyncManager dsm = DropboxSyncManager.getInstance(a);
	if (dsm != null && dsm.isSyncing())
		miDropbox.setChecked(true);
	
	ActionBar actionBar = getActivity().getActionBar();
	actionBar.setDisplayShowTitleEnabled(true);
	actionBar.setTitle(R.string.home_gallery_title);
	actionBar.setDisplayShowHomeEnabled(true);
	actionBar.setDisplayHomeAsUpEnabled(false);
	actionBar.setHomeButtonEnabled(true);
	actionBar.setLogo(this.getResources().getDrawable(
			R.drawable.ic_action_up));
	actionBar.setDisplayUseLogoEnabled(true);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
 
Example 27
Source Project: BotLibre   Source File: SearchIssuesActivity.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	BrowseConfig config = new BrowseConfig();
	
	config.typeFilter = "Public";
	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	if (radio.isChecked()) {
		config.typeFilter = "Personal";
	}
	Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin);
	config.sort = (String)sortSpin.getSelectedItem();
	AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText);
	config.tag = tagText.getText().toString();
	//AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	//config.category = categoryText.getText().toString();
	EditText filterEdit = (EditText)findViewById(R.id.filterText);
	config.filter = filterEdit.getText().toString();
	//CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox);
	//MainActivity.showImages = checkbox.isChecked();

	config.type = "Issue";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetIssuesAction(this, config);
	action.execute();
}
 
Example 28
Source Project: padland   Source File: EditPadDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected void setViewEvents() {
    fieldName = (EditText) main_view.findViewById(R.id.txt_pad_name);
    fieldLocalName = (EditText) main_view.findViewById(R.id.txt_pad_local_name);
    fieldGroup = (Spinner) main_view.findViewById( R.id.group_spinner );

    PadGroupModel padGroupModel = new PadGroupModel(getContext());
    ArrayList<PadGroup> allPadGroups = padGroupModel.getAllPadgroups();
    allPadGroups.add(new PadGroup(getContext()));
    spinnerAdapter = new SpinnerGroupAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, allPadGroups);

    fieldGroup.setAdapter(spinnerAdapter);

    if (edit_pad_id > 0) {
        PadModel model = new PadModel(getContext());
        Pad pad = model.getPadById(edit_pad_id);

        fieldName.setText(pad.getName());
        fieldLocalName.setText(pad.getRawLocalName());

        PadGroup padGroup = padGroupModel.getPadGroup(pad.getId());
        if( padGroup == null ) {
            padGroup = padGroupModel.getUnclassifiedPadGroup();
        }
        Log.d(TAG, String.valueOf(spinnerAdapter.getPosition(padGroup)));
        fieldGroup.setSelection(spinnerAdapter.getPosition(padGroup));
    }
}
 
Example 29
Source Project: SoBitmap   Source File: MediaStoreTask.java    License: Apache License 2.0 5 votes vote down vote up
public MediaStoreTask(Activity activity, Spinner target) {
    this.activity = activity;
    this.target = target;
    progressDialog = new ProgressDialog(activity);
    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);
}
 
Example 30
Source Project: an2linuxclient   Source File: ServerDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
void initViewsDialogEdit(View v, final Server server, final int serverListPosition) {
    pairingInfoTextView.setVisibility(View.GONE);
    final ServerDatabaseHandler dbHandler = ServerDatabaseHandler.getInstance(getActivity());

    certificateSpinner = (Spinner) v.findViewById(R.id.certificateSpinner);
    List<CertificateSpinnerItem> spinnerList = dbHandler.getSpinnerList();
    ArrayAdapter<CertificateSpinnerItem> spinnerArrayAdapter = new ArrayAdapter<>(
            getActivity().getApplicationContext(),
            R.layout.dialog_certificate_spinner_textview,
            spinnerList);

    spinnerArrayAdapter.setDropDownViewResource(R.layout.dialog_certificate_spinner_dropdown_textview);
    certificateSpinner.setAdapter(spinnerArrayAdapter);
    certificateSpinner.getBackground().setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
    certificateSpinner.setOnTouchListener(this);
    certificateSpinner.setOnItemSelectedListener(this);

    for (int i = 0; i < spinnerList.size(); i++){
        if (((CertificateIdAndFingerprint) spinnerList.get(i)).getId() == server.getCertificateId()){
            certificateSpinner.setSelection(i);
        }
    }

    v.findViewById(R.id.deleteServerBtn).setOnClickListener(view -> {
        dbHandler.deleteServer(server.getId());
        serverAdapterListCallbacks.deleteServer(serverListPosition);
        cancel();
    });

    dbHandler.close();
}