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

The following examples show how to use android.widget.Spinner#getSelectedItem() . 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: TransactionViewActivityTest.java    From budget-watch with GNU General Public License v3.0 6 votes vote down vote up
private void checkFieldProperties(final Activity activity, final int id, final int visibility,
                                  final String contents)
{
    final View view = activity.findViewById(id);
    assertNotNull(view);
    assertEquals(visibility, view.getVisibility());
    if(contents != null)
    {
        if(view instanceof TextView)
        {
            TextView textView = (TextView)view;
            assertEquals(contents, textView.getText().toString());
        }

        if(view instanceof Spinner)
        {
            Spinner spinner = (Spinner)view;
            String selection = (String)spinner.getSelectedItem();
            assertNotNull(selection);
            assertEquals(contents, selection);
        }
    }
}
 
Example 2
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void viewUser() {
	viewUser = user;
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	Intent intent = new Intent(this, ViewUserActivity.class);
	startActivity(intent);
}
 
Example 3
Source File: TrainingActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public ResponseConfig getSelectedResponse() {
	Spinner spin = (Spinner) findViewById(R.id.responseTypeSpin);
	String type = (String)spin.getSelectedItem();
       ListView list = (ListView) findViewById(R.id.responseList);
       int index = list.getCheckedItemPosition();
	if (index < 0) {
		return null;
	}
	
	if (type.equals("conversations")) {
		Object selected = this.conversationInput.get(index);
		if (selected instanceof ConversationConfig) {
			return null;
		} else {
			ResponseConfig response = new ResponseConfig();
			response.response = ((InputConfig)selected).value;
			if (index > 1) {
				Object previous = this.conversationInput.get(index - 1);
				if (previous instanceof InputConfig) {
					response.question = ((InputConfig)previous).value;
				}
			}
			return response;
		}
	} else {
		return this.responses.get(index);
	}
}
 
Example 4
Source File: SettingsFragment.java    From android-overlay-protection with Apache License 2.0 5 votes vote down vote up
private void save() {
    View view = getView();
    if (view != null) {
        Settings settings = new Settings();

        CheckBox nonSuppectedAppModeCheckbox = (CheckBox) view.findViewById(R.id.enabledAdvancedProtectionCheckBox);
        settings.setAdvancedMode(nonSuppectedAppModeCheckbox.isChecked());

        SeekBar uninstallSeekbar = (SeekBar) view.findViewById(R.id.uninstallTimeoutSeekBar);
        settings.setUninstallTimeoutSeconds(uninstallSeekbar.getProgress());

        SeekBar ignoreSeekbak = (SeekBar) view.findViewById(R.id.ignoreOnceTimeoutSeekBar);
        settings.setIgnoreOnceTimeoutSeconds(ignoreSeekbak.getProgress());

        Spinner detectionEngineSpinner = (Spinner) view.findViewById(R.id.detectionEngineSpinner);
        DetectionEngine selectedItem = (DetectionEngine) detectionEngineSpinner.getSelectedItem();
        settings.setDetectionEngine(selectedItem);

        Context ctx = getActivity().getApplicationContext();
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);

        String serialized = gson.toJson(settings);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(Settings.KEY_SETTINGS, serialized);
        editor.apply();
        Toast.makeText(ctx, "Settings saved!", Toast.LENGTH_SHORT).show();
        notifySettingsChanged();
    }
}
 
Example 5
Source File: ImportExportActivity.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
private DataFormat getSelectedFormat(int id)
{
    final Spinner fileFormatSpinner = (Spinner) findViewById(id);
    String name = (String)fileFormatSpinner.getSelectedItem();
    DataFormat format = _fileFormatMap.get(name);
    return format;
}
 
Example 6
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void help(View view) {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}
	super.help(view);
}
 
Example 7
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}
	if (type == null) {
		type = MainActivity.defaultType;
	}
	BrowseConfig config = new BrowseConfig();
	if (type.equals("Bots")) {
		config.type = "Bot";
	} else if (type.equals("Forums")) {
		config.type = "Forum";
	} else if (type.equals("Live Chat")) {
		config.type = "Channel";
	} else if (type.equals("Domains")) {
		config.type = "Domain";
	} else if (type.equals("Avatars")) {
		config.type = "Avatar";
	} else if (type.equals("Scripts")) {
		importingBotScript = false;
		config.type = "Script";
	} else if (type.equals("Graphics")) {
		config.type = "Graphic";
	}
	config.contentRating = MainActivity.contentRating;
	HttpGetInstancesAction action = new HttpGetInstancesAction(this, config);
	action.execute();
}
 
Example 8
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void editUser() {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	Intent intent = new Intent(this, EditUserActivity.class);
	startActivity(intent);
}
 
Example 9
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void createUser() {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	Intent intent = new Intent(this, CreateUserActivity.class);
	startActivity(intent);
}
 
Example 10
Source File: SearchPostsActivity.java    From BotLibre with 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 = (String)tagText.getText().toString();
	AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	config.category = (String)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 = "Post";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetPostsAction(this, config);
	action.execute();
}
 
Example 11
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void viewUser() {
	viewUser = user;
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	Intent intent = new Intent(this, ViewUserActivity.class);
	startActivity(intent);
}
 
Example 12
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void createUser() {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	Intent intent = new Intent(this, CreateUserActivity.class);
	startActivity(intent);
}
 
Example 13
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void resetLast() {
	String type = MainActivity.defaultType;
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String) spin.getSelectedItem();
		if (type.equals("Chat Bot Wars")) {
			spin.setSelection(0);
			war(null);
			return;
		}
	}
	if (type == null) {
		type = MainActivity.defaultType;
	}
	Button button = (Button) findViewById(R.id.lastButton);
	if (button != null) {
		SharedPreferences cookies = getPreferences(Context.MODE_PRIVATE);
		String last = null;
		if (type.equals("Forums")) {
			last = cookies.getString("forum", null);
		} else if (type.equals("Live Chat")) {
			last = cookies.getString("channel", null);
		} else if (type.equals("Domains")) {
			last = cookies.getString("domain", null);
		} else if (type.equals("Avatars")) {
			last = cookies.getString("avatar", null);
		} else if (type.equals("Scripts")) {
			last = cookies.getString("script", null);
		} else if (type.equals("Graphics")) {
			last = cookies.getString("graphic", null);
		} else {
			last = cookies.getString("instance", null);
		}

		if (last != null) {
			button.setText(last);
			button.setVisibility(View.VISIBLE);
		} else {
			button.setVisibility(View.GONE);
		}
	}

}
 
Example 14
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void logout() {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}
	connection.disconnect();
	user = null;
	instance = null;
	conversation = null;
	post = null;
	posts = new ArrayList<ForumPostConfig>();
	instances = new ArrayList<WebMediumConfig>();
	domain = null;
	tags = null;
	categories = null;
	learning = null;
	voice = null;
	customVoice = false;
	translate = false;

	SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit();
	editor.remove("user");
	editor.remove("token");
	editor.remove("instance");
	editor.remove("forum");
	editor.remove("channel");
	editor.remove("domain");
	editor.remove("avatar");
	editor.remove("graphic");
	editor.remove("voice");
	editor.remove("language");
	editor.remove("nativeVoice");
	editor.remove("translate");
	editor.remove("voiceConfigXML");
	editor.remove("customAvatar");
	editor.remove("avatarID");
	editor.remove("botId");
	editor.remove("deviceVoice");
	editor.commit();

	HttpGetImageAction.clearFileCache(this);

	Intent intent = getIntent();
	finish();
	startActivity(intent);
}
 
Example 15
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void logout() {
		Spinner spin = (Spinner) findViewById(R.id.typeSpin);
		if (spin != null) {
			type = (String)spin.getSelectedItem();
		}
		
		connection.disconnect();
        user = null;
        instance = null;
        conversation = null;
        post = null;
        posts = new ArrayList<ForumPostConfig>();
        instances = new ArrayList<WebMediumConfig>();
        domain = null;
        tags = null;
        categories= null;
        learning = null;
        voice = null;
        customVoice = false;
        translate = false;

		SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit();
		editor.putString("user", null);
		editor.putString("token", null);
		editor.putString("instance", null);
		editor.putString("forum", null);
		editor.putString("channel", null);
		editor.putString("domain", null);
		editor.putString("avatar", null);
		editor.putString("graphic", null);
		editor.putString("voice", null);
		editor.putString("language", null);
		editor.putString("nativeVoice", null);
		editor.putString("translate", null);
		editor.commit();

		HttpGetImageAction.clearFileCache(this);
	
		
//		Intent intent = getIntent();
//		finish();
//		startActivity(intent);
		active.onResume();
		
		this.frame.revalidate();
		this.frame.repaint();
	}
 
Example 16
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void resetMenu(Menu menu) {
	if (menu == null) {
		return;
	}
       for (int index = 0; index < menu.size(); index++) {
   	    menu.getItem(index).setEnabled(true);        	
       }
       if (MainActivity.user == null) {
       	menu.findItem(R.id.menuMyBots).setEnabled(false);
       	menu.findItem(R.id.menuSignOut).setEnabled(false);
       	menu.findItem(R.id.menuViewUser).setEnabled(false);
       	menu.findItem(R.id.menuEditUser).setEnabled(false);
       } else {
       	menu.findItem(R.id.menuSignIn).setEnabled(false);
       	menu.findItem(R.id.menuSignUp).setEnabled(false);
       }
       
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}
	if (type == null) {
		type = MainActivity.defaultType;
	}
	MenuItem item = menu.findItem(R.id.menuMyBots);
	if (type.equals("Bots")) {
		item.setTitle("My Bots");
	} else if (type.equals("Forums")) {
		item.setTitle("My Forums");
	} else if (type.equals("Live Chat")) {
		item.setTitle("My Channels");
	} else if (type.equals("Domains")) {
		item.setTitle("My Domains");
	} else if (type.equals("Avatars")) {
		item.setTitle("My Avatars");
	} else if (type.equals("Scripts")){
		item.setTitle("My Scripts");
	}else if (type.equals("Graphics")){
		item.setTitle("My Graphics");
	}
}
 
Example 17
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void logout() {
	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String)spin.getSelectedItem();
	}

	connection.disconnect();
	user = null;
	instance = null;
	conversation = null;
	post = null;
	posts = new ArrayList<ForumPostConfig>();
	instances = new ArrayList<WebMediumConfig>();
	domain = null;
	tags = null;
	categories = null;
	learning = null;
	voice = null;
	customVoice = false;
	translate = false;

	SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit();
	editor.putString("user", null);
	editor.putString("token", null);
	editor.putString("instance", null);
	editor.putString("forum", null);
	editor.putString("channel", null);
	editor.putString("domain", null);
	editor.putString("avatar", null);
	editor.putString("graphic", null);
	editor.putString("voice", null);
	editor.putString("language", null);
	editor.putString("nativeVoice", null);
	editor.putString("translate", null);
	editor.commit();

	HttpGetImageAction.clearFileCache(this);

	Intent intent = getIntent();
	finish();
	startActivity(intent);
}
 
Example 18
Source File: TGBrowserView.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TGBrowserCollection findSelectedCollection() {
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
	return (selectableItem != null ? (TGBrowserCollection) selectableItem.getItem() : null);
}
 
Example 19
Source File: TGHarmonicDialog.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int findSelectedData() {
	Spinner spinner = (Spinner) this.getView().findViewById(R.id.harmonic_dlg_data_value);
	TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
	return (selectableItem != null ? ((Integer)selectableItem.getItem()).intValue() : 0);
}
 
Example 20
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void resetMenu(Menu menu) {
	if (menu == null) {
		return;
	}
	for (int index = 0; index < menu.size(); index++) {
		menu.getItem(index).setEnabled(true);
	}
	if (MainActivity.user == null) {
		//menu.findItem(R.id.menuMyBots).setEnabled(false);
		//menu.findItem(R.id.menuSignOut).setEnabled(false);
		//menu.findItem(R.id.menuViewUser).setEnabled(false);
		//menu.findItem(R.id.menuEditUser).setEnabled(false);
	} else {
		//menu.findItem(R.id.menuSignIn).setEnabled(false);
		//menu.findItem(R.id.menuSignUp).setEnabled(false);
	}

	if (MicroMemory.checkExists()) {
		menu.findItem(R.id.menuDeleteExistingBot).setEnabled(true);
	} else {
		menu.findItem(R.id.menuDeleteExistingBot).setEnabled(false);
	}

	Spinner spin = (Spinner) findViewById(R.id.typeSpin);
	if (spin != null) {
		type = (String) spin.getSelectedItem();
	}
	if (type == null) {
		type = MainActivity.defaultType;
	}
	// MenuItem item = menu.findItem(R.id.menuMyBots);
	// if (type.equals("Bots")) {
	// item.setTitle("My Bots");
	// } else if (type.equals("Forums")) {
	// item.setTitle("My Forums");
	// } else if (type.equals("Live Chat")) {
	// item.setTitle("My Channels");
	// } else if (type.equals("Domains")) {
	// item.setTitle("My Domains");
	// } else if (type.equals("Avatars")) {
	// item.setTitle("My Avatars");
	// } else if (type.equals("Scripts")){
	// item.setTitle("My Scripts");
	// }else if (type.equals("Graphics")){
	// item.setTitle("My Graphics");
	// }
}