Java Code Examples for android.widget.Spinner#setOnItemSelectedListener()

The following examples show how to use android.widget.Spinner#setOnItemSelectedListener() . 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 check out the related API usage on the sidebar.
Example 1
Source File: DistrictActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.district_activity);

	tv_countryInfo = (TextView) findViewById(R.id.tv_countryInfo);
	tv_provinceInfo = (TextView) findViewById(R.id.tv_provinceInfo);
	tv_cityInfo = (TextView) findViewById(R.id.tv_cityInfo);
	tv_districtInfo = (TextView) findViewById(R.id.tv_districtInfo);

	spinnerProvince = (Spinner) findViewById(R.id.spinner_province);
	spinnerCity = (Spinner) findViewById(R.id.spinner_city);
	spinnerDistrict = (Spinner) findViewById(R.id.spinner_district);

	spinnerProvince.setOnItemSelectedListener(this);
	spinnerCity.setOnItemSelectedListener(this);
	spinnerDistrict.setOnItemSelectedListener(this);

	init();
}
 
Example 2
Source File: AutoBrightnessDialogPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    mSpinLevels = (Spinner) view.findViewById(R.id.spinLevels);
    mSpinLevels.setOnItemSelectedListener(this);

    mTxtLux = (EditText) view.findViewById(R.id.txtLux);
    mTxtBrightness = (EditText) view.findViewById(R.id.txtBrightness);

    TextView label = (TextView) view.findViewById(R.id.label2);
    if (label != null) {
        label.setText(String.format(
                getContext().getString(R.string.pref_ab_brighness_label),
                mBrightnessMin));
    }

    mBtnSet = (Button) view.findViewById(R.id.btnSet);
    mBtnSet.setOnClickListener(this);

    if (getConfig()) {
        setData();
    }

    super.onBindDialogView(view);
}
 
Example 3
Source File: OrderActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_order);
    Spinner spinner = findViewById(R.id.label_spinner);
    if (spinner != null) {
        spinner.setOnItemSelectedListener(this);
    }
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.labels_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    if (spinner != null) {
        spinner.setAdapter(adapter);
    }
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    TextView textview = findViewById(R.id.message);
    textview.setText(message);
}
 
Example 4
Source File: IconPreference.java    From AppOpsXposed with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onBindView(View view)
{
	super.onBindView(view);
	mSpinner = (Spinner) view.findViewById(R.id.spinnerWidget);

	final ViewParent parent = mSpinner.getParent();
	if(parent instanceof View)
	{
		final Rect rect  = new Rect(0, 0, ((View) parent).getWidth(),
				((View) parent).getHeight());
		((View) parent).setTouchDelegate(new TouchDelegate(rect, (View) parent));

	}

	updateSpinner();
	mSpinner.setOnItemSelectedListener(this);
}
 
Example 5
Source File: MongolLabelActivity.java    From mongol-library with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mongol_label);

    mMongolLabelMatchParent = findViewById(R.id.mongol_label_matchparent);
    mMongolLabelWrapContent = findViewById(R.id.mongol_label_wrapcontent);

    // Color choice spinner
    Spinner colorSpinner = findViewById(R.id.fontcolor_spinner);
    ArrayAdapter<String> adapterColor = new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_item, fontColors);
    adapterColor.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    colorSpinner.setAdapter(adapterColor);
    colorSpinner.setOnItemSelectedListener(this);

    // Font size spinner
    Spinner sizeSpinner = findViewById(R.id.fontsize_spinner);
    ArrayAdapter<String> adapterFontSizes = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, fontSizesSP);
    adapterFontSizes.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sizeSpinner.setAdapter(adapterFontSizes);
    sizeSpinner.setSelection(2); // 30sp
    sizeSpinner.setOnItemSelectedListener(this);
}
 
Example 6
Source File: PlayMovieSurfaceActivity.java    From pause-resume-video-recording with 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_surface);

    mSurfaceView = (SurfaceView) findViewById(R.id.playMovie_surface);
    mSurfaceView.getHolder().addCallback(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(Environment.getExternalStorageDirectory(), "*.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 7
Source File: MainActivity.java    From external-nfc-api with Apache License 2.0 5 votes vote down vote up
private void createModeSpinner(View rootView) {
    modeSpinner = (Spinner) rootView.findViewById(R.id.mode_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity, R.array.service_modes, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    modeSpinner.setAdapter(adapter);

    ModeListener modeListener = new ModeListener(activity, rootView);
    modeSpinner.setOnItemSelectedListener(modeListener);

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    int selection = prefs.getInt("mode", 0);
    modeSpinner.setSelection(selection);
    modeListener.displayItem(selection);
}
 
Example 8
Source File: FileSelector.java    From IPTVFree with Apache License 2.0 5 votes vote down vote up
private void prepareFilterSpinner(String[] fitlesFilter) {
	mFilterSpinner = (Spinner) mDialog.findViewById(R.id.fileFilter);
	if (fitlesFilter == null || fitlesFilter.length == 0) {
		fitlesFilter = new String[] { FileUtils.FILTER_ALLOW_ALL };
		mFilterSpinner.setEnabled(false);
	}
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.spinner_item, fitlesFilter);

	mFilterSpinner.setAdapter(adapter);
	OnItemSelectedListener onItemSelectedListener = new OnItemSelectedListener() {

		@Override
		public void onItemSelected(AdapterView<?> aAdapter, View aView, int arg2, long arg3) {
			TextView textViewItem = (TextView) aView;
			String filtr = textViewItem.getText().toString();
			makeList(mCurrentLocation, filtr);
		}

		@Override
		public void onNothingSelected(AdapterView<?> arg0) {

		}
	};
	mFilterSpinner.setOnItemSelectedListener(onItemSelectedListener);
}
 
Example 9
Source File: OverlayActivity.java    From android with Apache License 2.0 5 votes vote down vote up
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  Spinner spinner = (Spinner) findViewById(R.id.overlay_spinner);
  ArrayAdapter<CharSequence> adapter =
      ArrayAdapter.createFromResource(this, R.array.overlay_array, R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(itemSelectedListener);
}
 
Example 10
Source File: MainActivity.java    From ADBToolKitsInstaller with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    adbCheckBox = (CheckBox) findViewById(R.id.adb);
    fastbootCheckBox = (CheckBox) findViewById(R.id.fastboot);
    spinner = (Spinner) findViewById(R.id.spinner);
    adbServerStatus = findViewById(R.id.text_view_adb_server);
    adbIpAddress = findViewById(R.id.text_view_ip_address);
    adbPort = findViewById(R.id.text_view_adb_port);
    adbBinary = findViewById(R.id.text_view_adb_location);
    fastbootBinary = findViewById(R.id.text_view_fastboot_location);
    adbCheckBox.setOnCheckedChangeListener(this);
    fastbootCheckBox.setOnCheckedChangeListener(this);
    Collections.addAll(locations, getResources().getStringArray(R.array.locations));
    adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, locations);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setOnItemSelectedListener(this);
    spinner.setAdapter(adapter);
    mButtons.install = findViewById(R.id.install);
    mButtons.uninstall = findViewById(R.id.uninstall);
    mButtons.startAdbServer = findViewById(R.id.start_adb_service);
    mButtons.stopAdbServer = findViewById(R.id.stop_adb_service);
    mButtons.runCommands = findViewById(R.id.run_commands);
    mButtons.refresh = findViewById(R.id.refersh);
    mButtons.setOnClickListener(this);
    refreshAll();
}
 
Example 11
Source File: MainActivity.java    From AboutIt with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.app_name);

    Spinner spinner = findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(this);

    mSampleText = findViewById(R.id.sample_text);
}
 
Example 12
Source File: MainActivity.java    From GestureTutorial with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	spinAnimation = (Spinner) findViewById(R.id.spinAnimation);
	spinLocation = (Spinner) findViewById(R.id.spinLocation);

	spinAnimation.setOnItemSelectedListener(this);
	spinLocation.setOnItemSelectedListener(this);
	tv = TutorialView.create(this, TutorialView.DoubleFingerTap, location,
			findViewById(R.id.exampleArea));
	tv.show();
}
 
Example 13
Source File: FoldingLayoutActivity.java    From FoldingLayout with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (IS_JBMR2) {
        getMenuInflater().inflate(R.menu.fold_with_bug, menu);
    } else {
        getMenuInflater().inflate(R.menu.fold, menu);
    }
    Spinner s = (Spinner) menu.findItem(R.id.num_of_folds).getActionView();
    s.setOnItemSelectedListener(mItemSelectedListener);
    return true;
}
 
Example 14
Source File: SpinnerActivity.java    From androidtestdebug with MIT License 4 votes vote down vote up
/**
 * Initializes the application and the activity.
 * 1) Sets the view
 * 2) Reads the spinner's backing data from the string resources file
 * 3) Instantiates a callback listener for handling selection from the
 *    spinner
 * Notice that this method includes code that can be uncommented to force
 * tests to fail.
 *
 * This method overrides the default onCreate() method for an Activity.
 *
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
public void onCreate(Bundle savedInstanceState) {

    /**
     * derived classes that use onCreate() overrides must always call the super constructor
     */
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    Spinner spinner = (Spinner) findViewById(R.id.Spinner01);

    /*
     * Create a backing mLocalAdapter for the Spinner from a list of the
     * planets. The list is defined by XML in the strings.xml file.
     */

    this.mAdapter = ArrayAdapter.createFromResource(this, R.array.Planets,
            android.R.layout.simple_spinner_dropdown_item);

    /*
     * Attach the mLocalAdapter to the spinner.
     */

    spinner.setAdapter(this.mAdapter);

    /*
     * Create a listener that is triggered when Android detects the
     * user has selected an item in the Spinner.
     */

    OnItemSelectedListener spinnerListener = new myOnItemSelectedListener(this,this.mAdapter);

    /*
     * Attach the listener to the Spinner.
     */

    spinner.setOnItemSelectedListener(spinnerListener);


    /*
     * To demonstrate a failure in the preConditions test,
     * uncomment the following line.
     * The test will fail because the selection listener for the
     * Spinner is not set.
     */
     // spinner.setOnItemSelectedListener(null);

}
 
Example 15
Source File: GeoGeneratorActivity.java    From SecScanQR with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneralHandler generalHandler = new GeneralHandler(this);
    generalHandler.loadTheme();
    setContentView(R.layout.activity_geo_generator);
    tfLatitude = (EditText) findViewById(R.id.tfLatitude);
    tfLongtitude = (EditText) findViewById(R.id.tfLongtitude);
    cbLatitude = (CheckBox) findViewById(R.id.cbLatitude);
    cbLongtitude = (CheckBox) findViewById(R.id.cbLongtitude);
    btnGenerate = (Button) findViewById(R.id.btnGenerateGeo);

    btnGenerate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            latitude = tfLatitude.getText().toString().trim();
            longtitude = tfLongtitude.getText().toString().trim();
            if(latitude.equals("") || longtitude.equals("")){
                Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_geo_first), Toast.LENGTH_SHORT).show();
            } else {
                multiFormatWriter = new MultiFormatWriter();
                try{
                    if(north && east) {
                        geo = "geo:" + latitude + "," + longtitude;
                    } else if (!east && north){
                        geo = "geo:" + latitude + ",-" + longtitude;
                    } else if (!north && east){
                        geo = "geo:-" + latitude + "," + longtitude;
                    } else {
                        geo = "geo:-" + latitude + ",-" + longtitude;
                    }
                    openResultActivity();
                } catch (Exception e){
                    Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
                }
            }
        }
    });

    //Setup the Spinner Menu for the different formats
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.formats_geo_array, R.layout.spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    //If the device were rotated then restore information
    if(savedInstanceState != null){
        latitude = (String) savedInstanceState.get(STATE_LATITUDE);
        tfLatitude.setText(latitude);
        longtitude = (String) savedInstanceState.get(STATE_LONGTITUDE);
        tfLongtitude.setText(longtitude);
        north = (Boolean) savedInstanceState.get(STATE_NORTH);
        if(!north){
            cbLatitude.setChecked(false);
        }
        east = (Boolean) savedInstanceState.get(STATE_EAST);
        if(!east){
            cbLongtitude.setChecked(false);
        }
    }
}
 
Example 16
Source File: DrMIPSActivity.java    From drmips with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates/places the tabs in the Tabhost.
 */
private void createTabs() {
	tabHost = (TabHost)findViewById(android.R.id.tabhost);
	tabHost.setup();

	TabSpec tabCode = tabHost.newTabSpec("tabCode");
	tabCode.setIndicator(getString(R.string.code));
	tabCode.setContent(R.id.tabCode);
	tabHost.addTab(tabCode);
	txtCode = (EditText)findViewById(R.id.txtCode);
	lblFilename = (TextView)findViewById(R.id.lblFilename);
	txtCode.addTextChangedListener(new CodeEditorTextWatcher());
	
	TabSpec tabAssembledCode = tabHost.newTabSpec("tabAssembledCode");
	tabAssembledCode.setIndicator(getString(R.string.assembled));
	tabAssembledCode.setContent(R.id.tabAssembledCode);
	tabHost.addTab(tabAssembledCode);
	tblAssembledCode = (TableLayout)findViewById(R.id.tblAssembledCode);
	cmbAssembledCodeFormat = (Spinner)findViewById(R.id.cmbAssembledCodeFormat);
	cmbAssembledCodeFormat.setOnItemSelectedListener(spinnersListener);
	cmbAssembledCodeFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.ASSEMBLED_CODE_FORMAT_PREF, DrMIPS.DEFAULT_ASSEMBLED_CODE_FORMAT));
	
	TabSpec tabDatapath = tabHost.newTabSpec("tabDatapath");
	tabDatapath.setIndicator(getString(R.string.datapath));
	tabDatapath.setContent(R.id.tabDatapath);
	tabHost.addTab(tabDatapath);
	lblCPUFilename = (TextView)findViewById(R.id.lblCPUFilename);
	cmdStep = (ImageButton)findViewById(R.id.cmdStep);
	datapathScroll = (HorizontalScrollView)findViewById(R.id.datapathScroll);
	boolean performanceMode = DrMIPS.getApplication().getPreferences().getBoolean(DrMIPS.PERFORMANCE_MODE_PREF, DrMIPS.DEFAULT_PERFORMANCE_MODE);
	lblDatapathFormat = (TextView)findViewById(R.id.lblDatapathFormat);
	cmbDatapathFormat = (Spinner)findViewById(R.id.cmbDatapathFormat);
	cmbDatapathFormat.setOnItemSelectedListener(spinnersListener);
	cmbDatapathFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATAPATH_DATA_FORMAT_PREF, DrMIPS.DEFAULT_DATAPATH_DATA_FORMAT));
	lblDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathFormat.setVisibility(performanceMode ? View.GONE : View.VISIBLE);
	lblDatapathPerformance = (TextView)findViewById(R.id.lblDatapathPerformance);
	cmbDatapathPerformance = (Spinner)findViewById(R.id.cmbDatapathPerformance);
	cmbDatapathPerformance.setOnItemSelectedListener(spinnersListener);
	cmbDatapathPerformance.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.PERFORMANCE_TYPE_PREF, DrMIPS.DEFAULT_PERFORMANCE_TYPE));
	lblDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	cmbDatapathPerformance.setVisibility(!performanceMode ? View.GONE : View.VISIBLE);
	tblExec = (TableLayout)findViewById(R.id.tblExec);
	tblExecRow = (TableRow)findViewById(R.id.tblExecRow);
	
	TabSpec tabRegisters = tabHost.newTabSpec("tabRegisters");
	tabRegisters.setIndicator(getString(R.string.registers));
	tabRegisters.setContent(R.id.tabRegisters);
	tabHost.addTab(tabRegisters);
	tblRegisters = (TableLayout)findViewById(R.id.tblRegisters);
	cmbRegistersFormat = (Spinner)findViewById(R.id.cmbRegistersFormat);
	cmbRegistersFormat.setOnItemSelectedListener(spinnersListener);
	cmbRegistersFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.REGISTER_FORMAT_PREF, DrMIPS.DEFAULT_REGISTER_FORMAT));
	
	TabSpec tabDataMemory = tabHost.newTabSpec("tabDataMemory");
	tabDataMemory.setIndicator(getString(R.string.data_memory));
	tabDataMemory.setContent(R.id.tabDataMemory);
	tabHost.addTab(tabDataMemory);
	tblDataMemory = (TableLayout)findViewById(R.id.tblDataMemory);
	cmbDataMemoryFormat = (Spinner)findViewById(R.id.cmbDataMemoryFormat);
	cmbDataMemoryFormat.setOnItemSelectedListener(spinnersListener);
	cmbDataMemoryFormat.setSelection(DrMIPS.getApplication().getPreferences().getInt(DrMIPS.DATA_MEMORY_FORMAT_PREF, DrMIPS.DEFAULT_DATA_MEMORY_FORMAT));
}
 
Example 17
Source File: SpinnerWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SpinnerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    mItems = getSelectChoices();
    spinner = new Spinner(context);
    choices = new String[mItems.size()];

    for (int i = 0; i < mItems.size(); i++) {
        choices[i] = prompt.getSelectChoiceText(mItems.get(i));
    }

    // The spinner requires a custom adapter. It is defined below
    SpinnerAdapter adapter =
            new SpinnerAdapter(getContext(), android.R.layout.simple_spinner_item,
                    getChoicesWithEmptyFirstSlot(choices),
                    TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);

    spinner.setAdapter(adapter);
    spinner.setPrompt(prompt.getQuestionText());
    spinner.setEnabled(!prompt.isReadOnly());
    spinner.setFocusable(!prompt.isReadOnly());

    // Fill in previous answer
    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    if (s != null) {
        for (int i = 0; i < mItems.size(); ++i) {
            String sMatch = mItems.get(i).getValue();
            if (sMatch.equals(s)) {
                // Workaround to a really weird spinner bug that triggers onItemSelected
                // in the initial selection of spinner even though no listener is set.
                // https://stackoverflow.com/a/17336944/6671572
                spinner.setSelection(i+1, false);
            }
        }
    }

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            widgetEntryChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            //do nothing here
        }

    });

    addView(spinner);

}
 
Example 18
Source File: PopupComposeStatus.java    From Rumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_popup_compose_status);

    Bundle args = getIntent().getExtras();
    if(args != null) {
        this.filter_gid = args.getString("GroupID");
        this.filter_hashtag = args.getString("Hashtag");
    }

    imageBitmap = null;
    dismiss = (LinearLayout)(findViewById(R.id.popup_dismiss));
    compose = (EditText)(findViewById(R.id.popup_user_status));
    compose_background = (ImageView)(findViewById(R.id.popup_user_attached_photo));
    takePicture = (ImageButton)(findViewById(R.id.popup_take_picture));
    choosePicture = (ImageButton)(findViewById(R.id.popup_choose_image));
    send = (ImageButton)(findViewById(R.id.popup_button_send));
    spinner = (Spinner)(findViewById(R.id.group_list_spinner));
    groupLock = (ImageView)(findViewById(R.id.group_lock_image));

    groupLock.setBackgroundResource(R.drawable.ic_lock_outline_white_24dp);

    if(filter_gid == null) {
        spinnerArrayAdapter = new GroupSpinnerAdapter();
        spinner.setAdapter(spinnerArrayAdapter);
        spinner.setOnItemSelectedListener(spinnerArrayAdapter);
        getGroupList();
    } else {
        spinner.setVisibility(View.INVISIBLE);
    }

    if(filter_hashtag != null) {
        compose.setText(filter_hashtag);
    }

    dismiss.setOnClickListener(onDiscardClick);
    takePicture.setOnClickListener(onTakePictureClick);
    choosePicture.setOnClickListener(onAttachPictureClick);
    send.setOnClickListener(onClickSend);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
 
Example 19
Source File: DrawableTintingFragment.java    From android-DrawableTinting with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.tinting_fragment, null);

    // Set a drawable as the image to display
    mImage = (ImageView) v.findViewById(R.id.image);
    mImage.setImageResource(R.drawable.btn_default_normal_holo);

    // Get text labels and seekbars for the four color components: ARGB
    mAlphaBar = (SeekBar) v.findViewById(R.id.alphaSeek);
    mAlphaText = (TextView) v.findViewById(R.id.alphaText);
    mGreenBar = (SeekBar) v.findViewById(R.id.greenSeek);
    mGreenText = (TextView) v.findViewById(R.id.greenText);
    mRedBar = (SeekBar) v.findViewById(R.id.redSeek);
    mRedText = (TextView) v.findViewById(R.id.redText);
    mBlueText = (TextView) v.findViewById(R.id.blueText);
    mBlueBar = (SeekBar) v.findViewById(R.id.blueSeek);

    // Set a listener to update tinted image when selections have changed
    mAlphaBar.setOnSeekBarChangeListener(mSeekBarListener);
    mRedBar.setOnSeekBarChangeListener(mSeekBarListener);
    mGreenBar.setOnSeekBarChangeListener(mSeekBarListener);
    mBlueBar.setOnSeekBarChangeListener(mSeekBarListener);


    // Set up the spinner for blend mode selection from a string array resource
    mBlendSpinner = (Spinner) v.findViewById(R.id.blendSpinner);
    SpinnerAdapter sa = ArrayAdapter.createFromResource(getActivity(),
            R.array.blend_modes, android.R.layout.simple_spinner_dropdown_item);
    mBlendSpinner.setAdapter(sa);
    // Set a listener to update the tinted image when a blend mode is selected
    mBlendSpinner.setOnItemSelectedListener(mBlendListener);
    // Select the first item
    mBlendSpinner.setSelection(0);
    mMode = MODES[0];

    if (savedInstanceState != null) {
        // Restore the previous state if this fragment has been restored
        mBlendSpinner.setSelection(savedInstanceState.getInt(STATE_BLEND));
        mAlphaBar.setProgress(savedInstanceState.getInt(STATE_ALPHA));
        mRedBar.setProgress(savedInstanceState.getInt(STATE_RED));
        mGreenBar.setProgress(savedInstanceState.getInt(STATE_GREEN));
        mBlueBar.setProgress(savedInstanceState.getInt(STATE_BLUE));
    }

    // Apply the default blend mode and color
    updateTint(getColor(), getTintMode());

    return v;
}
 
Example 20
Source File: StandaloneActivity.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    if(Utils.hasLollipop()){
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
    else if(Utils.hasKitKat()){
        setTheme(R.style.Theme_Document_Translucent);
    }
    setUpStatusBar();
    // Debug.waitForDebugger();
    super.onCreate(icicle);
    mRoots = DocumentsApplication.getRootsCache(this);
    setResult(Activity.RESULT_CANCELED);
    setContentView(R.layout.activity);
    final Context context = this;
    final Resources res = getResources();
    // Strongly define our horizontal dimension; we leave vertical as
    final WindowManager.LayoutParams a = getWindow().getAttributes();
    final Point size = new Point();
    getWindowManager().getDefaultDisplay().getSize(size);
    // a.width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x);
    getWindow().setAttributes(a);
    mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory);
    if (icicle != null) {
        mState = icicle.getParcelable(EXTRA_STATE);
    } else {
        buildDefaultState();
    }
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitleTextAppearance(context,
            android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
    mToolbarStack = (Spinner) findViewById(R.id.stack);
    mToolbarStack.setOnItemSelectedListener(mStackListener);
    mRootsToolbar = (Toolbar) findViewById(R.id.roots_toolbar);
    if (mRootsToolbar != null) {
        mRootsToolbar.setTitleTextAppearance(context,
                android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
    }
    setSupportActionBar(mToolbar);
    RootsFragment.show(getFragmentManager(), null);
    if (!mState.restored) {
        new RestoreStackTask().execute();
    } else {
        onCurrentDirectoryChanged(ANIM_NONE);
    }
}