下面列出了android.widget.Spinner#getSelectedItem ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
}
}
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);
}
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);
}
}
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();
}
}
private DataFormat getSelectedFormat(int id)
{
final Spinner fileFormatSpinner = (Spinner) findViewById(id);
String name = (String)fileFormatSpinner.getSelectedItem();
DataFormat format = _fileFormatMap.get(name);
return format;
}
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();
}
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);
}
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);
}
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();
}
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);
}
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);
}
public void help(View view) {
Spinner spin = (Spinner) findViewById(R.id.typeSpin);
if (spin != null) {
type = (String)spin.getSelectedItem();
}
super.help(view);
}
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);
}
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");
// }
}
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);
}
public TGBrowserCollection findSelectedCollection() {
Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
TGSelectableItem selectableItem = (TGSelectableItem) spinner.getSelectedItem();
return (selectableItem != null ? (TGBrowserCollection) selectableItem.getItem() : null);
}
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);
}
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");
}
}
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();
}
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);
}
}
}