@Override public boolean onOptionsItemSelected(MenuItem item) { String title = (String) item.getTitle(); if (title.equals("添加")) { final HashMap<String, String> add_journal = new HashMap<String, String>(); LayoutInflater inflater = LayoutInflater.from(this); LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.journal_clickitem, null); AlertDialog.Builder builder = new AlertDialog.Builder(Record_Journal.this); final EditText titleEditText = (EditText) linearLayout.findViewById(R.id.journal_title_editText); final EditText contentEditText = (EditText) linearLayout.findViewById(R.id.journal_content_editText); titleEditText.setEnabled(true); contentEditText.setEnabled(true); builder.setPositiveButton( "保 存", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // To change body of implemented methods use File | Settings | File Templates. add_journal.put("title", String.valueOf(titleEditText.getText())); add_journal.put("body", String.valueOf(contentEditText.getText())); String date = String.valueOf(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); add_journal.put("time", date); add_journal.put("userID", Login.userID); if (myJournalNetwork.add(add_journal)) { Toast.makeText(Record_Journal.this, "添加成功", Toast.LENGTH_SHORT); } else { Toast.makeText(Record_Journal.this, "添加失败", Toast.LENGTH_SHORT); } record_journal_adapter.notifyDataSetChanged(); } }); builder.setNegativeButton( "取 消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // To change body of implemented methods use File | Settings | File Templates. } }); builder.setTitle("添加日志").setView(linearLayout); builder.show(); } else if (title.equals("帮助")) { Menu_Functions.helpMe(this); } else if (title.equals("联系")) { Menu_Functions.contactMe(this); } return super.onOptionsItemSelected( item); // To change body of overridden methods use File | Settings | File Templates. }
@Override public void onActivityCreated(Bundle aSavedState) { super.onActivityCreated(aSavedState); setRetainInstance(true); mMessage.setBackgroundColor(mPrefs.postBackgroundColor); mMessage.setTextColor(mPrefs.postFontColor); mExtras = getExtras(); mReplyType = mExtras.getInt(Constants.EDITING, getArguments().getInt(Constants.EDITING, -1)); mPostId = mExtras.getInt(Constants.POST_ID, getArguments().getInt(Constants.POST_ID, -1)); mThreadId = mExtras.getInt(Constants.THREAD_ID, getArguments().getInt(Constants.THREAD_ID, -1)); if (mReplyType < 0 || mThreadId < 0 || (mReplyType != AwfulMessage.TYPE_NEW_REPLY && mPostId < 0)) { Log.e(TAG, "MISSING ARGUMENTS!"); getActivity().finish(); } ((AwfulActivity) getActivity()).registerSyncService(mMessenger, mThreadId); getActivity() .getSupportLoaderManager() .restartLoader(Constants.REPLY_LOADER_ID, null, mReplyDataCallback); getActivity() .getContentResolver() .registerContentObserver(AwfulMessage.CONTENT_URI_REPLY, true, mReplyDataCallback); if (((AwfulActivity) getActivity()).isTV()) { mTitle.setText(getString(R.string.post_reply)); mSubmit.setOnClickListener(onSubmitClick); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.time_dialog); etxtTime = (EditText) findViewById(R.id.etxtTime); spTimeUnit = (Spinner) findViewById(R.id.spTimeUnit); butConfirm = (Button) findViewById(R.id.butConfirm); butCancel = (Button) findViewById(R.id.butCancel); butConfirm.setText(R.string.set_sleeptimer_label); butCancel.setText(R.string.cancel_label); setTitle(R.string.set_sleeptimer_label); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>( this.getContext(), android.R.layout.simple_spinner_item, spinnerContent); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spTimeUnit.setAdapter(spinnerAdapter); spTimeUnit.setSelection(DEFAULT_SPINNER_POSITION); butCancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); butConfirm.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { try { long input = readTimeMillis(); onTimeEntered(input); dismiss(); } catch (NumberFormatException e) { e.printStackTrace(); Toast toast = Toast.makeText(context, R.string.time_dialog_invalid_input, Toast.LENGTH_LONG); toast.show(); } } }); etxtTime.addTextChangedListener( new TextWatcher() { @Override public void afterTextChanged(Editable s) { checkInputLength(s.length()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }); checkInputLength(etxtTime.getText().length()); }
/** * 验证信息是否为空 * * @return */ private boolean verification() { name = et_user_name.getText().toString(); idcard = et_user_card.getText().toString(); bankid = et_user_ban.getText().toString(); phone = et_user_phone.getText().toString(); bankname = tv_bank_name.getText().toString(); if ("".equals(bankname)) { TXWLApplication.getInstance().showTextToast("银行不能为空"); return false; } if (DataVeri.isBlank(name)) { TXWLApplication.getInstance().showTextToast("真实姓名不能为空"); return false; } if (DataVeri.isBlank(idcard)) { TXWLApplication.getInstance().showTextToast("证件号码不能为空"); return false; } if (DataVeri.isBlank(bankid)) { TXWLApplication.getInstance().showTextToast("银行卡号不能为空"); return false; } return !DataVeri.isMobileNum(phone); }
private Dialog locationPicker() { AlertDialog.Builder locationPickerBuilder = new AlertDialog.Builder(this); locationPickerBuilder.setTitle("Set task location"); View content = getLayoutInflater() .inflate(R.layout.editlocation, (ViewGroup) findViewById(R.id.editLocation)); locationPickerBuilder.setView(content); EditText longitudeText = (EditText) content.findViewById(R.id.longitudeText); EditText latitudeText = (EditText) content.findViewById(R.id.latitudeText); latitudeText.setText(String.valueOf(location().latitude())); longitudeText.setText(String.valueOf(location().longitude())); locationPickerBuilder.setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Dialog locationPicker = (Dialog) dialogInterface; EditText longitudeText = (EditText) locationPicker.findViewById(R.id.longitudeText); EditText latitudeText = (EditText) locationPicker.findViewById(R.id.latitudeText); double longitude = Double.valueOf(longitudeText.getText().toString()); double latitude = Double.valueOf(latitudeText.getText().toString()); task.add(TaskAdapter.LOCATION, new CMGeoPoint(longitude, latitude)); setLocation(); } }); return locationPickerBuilder.create(); }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.ok: String user = userView.getText().toString(); if ("".equals(user)) { Toast.makeText(this, getString(R.string.EMPTY_USER_NAME), Toast.LENGTH_LONG).show(); return; } String account = (String) accountView.getSelectedItem(); if (account == null) { Toast.makeText(this, getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show(); return; } try { RosterManager.getInstance() .createContact(account, user, nameView.getText().toString(), getSelected()); PresenceManager.getInstance().requestSubscription(account, user); } catch (NetworkException e) { Application.getInstance().onError(e); finish(); return; } MessageManager.getInstance().openChat(account, user); finish(); break; default: break; } }
/** Called when the user selects the Send button */ public void sendMessage(View view) { Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(SAVED_ACCOUNT, (String) accountView.getSelectedItem()); outState.putString(SAVED_USER, userView.getText().toString()); outState.putString(SAVED_NAME, nameView.getText().toString()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); // // this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main_login); mEtAccount = (EditText) findViewById(R.id.mainLoginEditAccount); mEtPassword = (EditText) findViewById(R.id.mainLoginEditPassword); mBtnLogin = (Button) findViewById(R.id.mainLoginBtn); mBtnRegister = (Button) findViewById(R.id.main_btn_register); /* this is to render the password edittext font to be default */ mEtPassword.setTypeface(Typeface.DEFAULT); mEtPassword.setTransformationMethod(new PasswordTransformationMethod()); mBtnLogin.setOnClickListener( new OnClickListener() { public void onClick(View v) { MainActivity.this.tryLogin(); } }); mBtnRegister.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent intent0 = new Intent(MainActivity.this, RegisterActivity.class); startActivity(intent0); } }); }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent == mSpinnerGeology) { geologyIndex = position; new PreferencesUtil(getContext()).save("geologyIndex", geologyIndex); initConditions(getActivity()); initConditions(getActivity()); initConditiontValue(getActivity()); changeAllGeology(); } if (parent == mSpinnerCondition) { conditionIndex = position; initConditions(getActivity()); initConditiontValue(getActivity()); } if (parent == mSpinnerConditionValue) { conditionValueIndex = position; } String selectItem = null; try { selectItem = mSpinnerConditionValue.getSelectedItem().toString(); } catch (Exception e) { e.printStackTrace(); } slog.p(TAG, "selectItem " + selectItem); if (mETValue1 != null && mETValue2 != null) { if (selectItem != null && selectItem.equals("自定义")) { mETValue1.setVisibility(View.VISIBLE); mETValue2.setVisibility(View.VISIBLE); } else { mETValue1.setVisibility(View.GONE); mETValue2.setVisibility(View.GONE); } } }
private LinearLayout getMainBody() { LinearLayout llMainBody = new LinearLayout(getContext()); llMainBody.setOrientation(LinearLayout.VERTICAL); LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lpMain.weight = 1; int dp_4 = dipToPx(getContext(), 4); lpMain.setMargins(dp_4, dp_4, dp_4, dp_4); llMainBody.setLayoutParams(lpMain); LinearLayout llContent = new LinearLayout(getContext()); LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lpContent.weight = 1; llMainBody.addView(llContent, lpContent); // share content editor etContent = new EditText(getContext()); etContent.setGravity(Gravity.LEFT | Gravity.TOP); etContent.setBackgroundDrawable(null); etContent.setText(String.valueOf(shareParamMap.get("text"))); etContent.addTextChangedListener(this); LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpEt.weight = 1; etContent.setLayoutParams(lpEt); llContent.addView(etContent); llContent.addView(getThumbView()); llMainBody.addView(getBodyBottom()); return llMainBody; }
private void showUserHashDialog() { String userHash = NavigineApp.Settings.getString("user_hash", ""); LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.user_hash_dialog, null); _userEdit = (EditText) view.findViewById(R.id.user_hash_edit); _userEdit.setText(userHash); _userEdit.setTypeface(Typeface.MONOSPACE); // _userEdit.addTextChangedListener(new TextWatcher() // { // public void afterTextChanged(Editable s) { } // public void beforeTextChanged(CharSequence s, int start, int count, int after) { } // public void onTextChanged(CharSequence s, int start, int before, int count) // { // String text = _userEdit.getText().toString(); // int length = _userEdit.getText().length(); // // if (text.endsWith("-")) // return; // // if (count <= before) // return; // // if (length == 4 || length == 9 || length == 14) // { // _userEdit.setText((text + "-")); // _userEdit.setSelection(length + 1); // } // } // }); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext); alertBuilder.setView(view); alertBuilder.setTitle("Enter user ID"); alertBuilder.setNegativeButton( getString(R.string.cancel_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) {} }); alertBuilder.setPositiveButton( getString(R.string.ok_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) { String userHash = _userEdit.getText().toString(); SharedPreferences.Editor editor = NavigineApp.Settings.edit(); editor.putString("user_hash", userHash); editor.commit(); NavigineApp.applySettings(); refreshMapList(); } }); AlertDialog dialog = alertBuilder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
public void setEmailFieldHidden(boolean hidden) { EditText email = (EditText) findViewById(R.id.email); if (hidden) { email.setVisibility(View.GONE); } else { email.setVisibility(View.VISIBLE); } }
public boolean onSearchRequested() { EditText search_box = (EditText) findViewById(R.id.search_box); search_box.requestFocus(); // Return false so that Android doesn't try to run an actual search // dialog. return false; }
private EditText createRenameEditText(String fileName) { EditText editText = new EditText(this); editText.setText( fileName.substring(0, fileName.length() - FileController.FILE_EXTENSION.length())); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setSelection(editText.getText().length()); return editText; }
private void initializePassphrase() { createPassphraseView.setVisibility(View.VISIBLE); enterPassphraseView.setVisibility(View.GONE); newPassphraseEditText.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) { if (!isPasswordValid()) { showValidationError(); } else { twoViewSlider.showConfirmationField(); } } return false; } }); confirmNewPassphraseEditText.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) { if (!newEqualsConfirmation()) { showInequalityError(); twoViewSlider.showNewPasswordField(); } } return false; } }); Button createPassphraseButton = (Button) findViewById(R.id.btnCreate); createPassphraseButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (!isPasswordValid()) { showValidationError(); twoViewSlider.showNewPasswordField(); } else if (isConfirmationFieldEmpty()) { twoViewSlider.showConfirmationField(); } else if (!newEqualsConfirmation()) { showInequalityError(); twoViewSlider.showNewPasswordField(); } else { try { cacheWordHandler.setPassphrase( newPassphraseEditText.getText().toString().toCharArray()); } catch (GeneralSecurityException e) { Log.e(TAG, "Cacheword pass initialization failed: " + e.getMessage()); } } } }); }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.back: finish(); break; case R.id.button_djs: // 点击获得验证码 try { isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext()); isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext()); if (!isMobileNet && !isWifiNet) { Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { e.printStackTrace(); } mobile_str = mobile.getText().toString(); if (StringUtil.isNullOrEmpty(mobile_str)) { Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show(); return; } button_djs.setClickable(false); // 不可点击 MyTimer myTimer = new MyTimer(60000, 1000); myTimer.start(); getCard(); break; case R.id.next: // 下一步 try { isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext()); isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext()); if (!isMobileNet && !isWifiNet) { Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show(); return; } } catch (Exception e) { e.printStackTrace(); } mobile_str = mobile.getText().toString(); card_str = card.getText().toString(); if (StringUtil.isNullOrEmpty(mobile_str)) { Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show(); return; } if (StringUtil.isNullOrEmpty(card_str)) { Toast.makeText(this, R.string.reg_error_five, Toast.LENGTH_SHORT).show(); return; } getReg(); break; case R.id.quest: // 问题 break; } }
private void updatePortFromSecurityType() { ConnectionSecurity securityType = getSelectedSecurity(); updateAuthPlainTextFromSecurityType(securityType); // Remove listener so as not to trigger validateFields() which is called // elsewhere as a result of user interaction. mPortView.removeTextChangedListener(validationTextWatcher); mPortView.setText(String.valueOf(AccountCreator.getDefaultPort(securityType, mStoreType))); mPortView.addTextChangedListener(validationTextWatcher); }
@Override protected void onInflate(Bundle savedInstanceState) { setContentView(R.layout.contact_add); ListView listView = getListView(); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.contact_add_header, listView, false); listView.addHeaderView(view, null, false); accountView = (Spinner) view.findViewById(R.id.contact_account); accountView.setAdapter(new AccountChooseAdapter(this)); accountView.setOnItemSelectedListener(this); userView = (EditText) view.findViewById(R.id.contact_user); nameView = (EditText) view.findViewById(R.id.contact_name); ((Button) view.findViewById(R.id.ok)).setOnClickListener(this); String name; Intent intent = getIntent(); if (savedInstanceState != null) { account = savedInstanceState.getString(SAVED_ACCOUNT); user = savedInstanceState.getString(SAVED_USER); name = savedInstanceState.getString(SAVED_NAME); } else { account = getAccount(intent); user = getUser(intent); if (account == null || user == null) name = null; else { name = RosterManager.getInstance().getName(account, user); if (user.equals(name)) name = null; } } if (account == null) { Collection<String> accounts = AccountManager.getInstance().getAccounts(); if (accounts.size() == 1) account = accounts.iterator().next(); } if (account != null) { for (int position = 0; position < accountView.getCount(); position++) if (account.equals(accountView.getItemAtPosition(position))) { accountView.setSelection(position); break; } } if (user != null) userView.setText(user); if (name != null) nameView.setText(name); if (ACTION_SUBSCRIPTION_REQUEST.equals(intent.getAction())) { subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user); if (subscriptionRequest == null) { Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); finish(); return; } } else { subscriptionRequest = null; } }
/* * (non-Javadoc) * * @see android.app.Activity#onBackPressed() */ @Override public void onBackPressed() { if (filtered) { ContactListActivity.this.contact_adapter.getFilter().filter(""); EditText search_box = (EditText) findViewById(R.id.search_box); search_box.setText(""); filtered = false; } else { super.onBackPressed(); } }
private double getEditValue(EditText etvalue) { try { if (etvalue.getVisibility() == View.VISIBLE) { double value = Double.parseDouble(etvalue.getText().toString()); return value; } } catch (Exception e) { slog.e(TAG, "getMaxValue error mETValue1.getText() " + etvalue.getText()); e.printStackTrace(); } return -1; }
private boolean checkPassphrase() { if (enterPassphraseEditText.getText().toString().length() == 0) { return false; } try { // Check the passphrase entered by the user cacheWordHandler.setPassphrase(enterPassphraseEditText.getText().toString().toCharArray()); } catch (GeneralSecurityException e) { return handleIncorrectPassphrase(e); } return true; }
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { EditText et = (EditText) v; // If the event is a key-down event on the "Enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press Toast.makeText(HelloFormStuffActivity.this, et.getText(), Toast.LENGTH_SHORT).show(); return true; } return false; }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.codelayout); LinearLayout MyLinear = (LinearLayout) findViewById(R.id.mylinear); MyLinear.setOrientation(LinearLayout.HORIZONTAL); Button MyBtn = (Button) findViewById(R.id.mybutton); MyBtn.setTextSize(40); EditText MyEdit = (EditText) findViewById(R.id.myedit); MyEdit.setBackgroundColor(0xff00ff00); }
private void refreshList() { this.contact_adapter.clear(); ContactRepositoryInterface datasource = ContactRepositoryFactory.getInstance().getContactRepository(this, this); datasource.open(); for (Contact c : datasource.all()) { this.contact_adapter.add(c); } datasource.close(); this.contact_adapter.notifyDataSetChanged(); EditText search_box = (EditText) findViewById(R.id.search_box); contact_adapter.getFilter().filter(search_box.getText().toString()); }
@Override public void onClick(View v) { if (v.getId() == R.id.bbcode) { selectionStart = mMessage .getSelectionStart(); // work around the ICS text selection actionbar, bane of my // existence selectionEnd = mMessage.getSelectionEnd(); BBCodeFragment fragment = new BBCodeFragment(); fragment.show(getActivity().getSupportFragmentManager(), "select_bbcode_dialog"); } if (v.getId() == R.id.emotes) { Toast.makeText(v.getContext(), "EMOTIONALLY UNAVAILABLE", Toast.LENGTH_LONG).show(); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings); saveBoton = (Button) findViewById(R.id.button1); cancelBoton = (Button) findViewById(R.id.button2); et = (EditText) findViewById(R.id.editText1); prefs = getSharedPreferences("preferences", Context.MODE_PRIVATE); et.setText(String.valueOf(prefs.getLong("rad", 100))); spin = (Spinner) findViewById(R.id.spinner1); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.units, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spin.setAdapter(adapter); spin.setOnItemSelectedListener(new MyOnItemSelectedListener()); saveBoton.setOnClickListener(new OnClickSaveListener()); cancelBoton.setOnClickListener(new OnClickCancelListener()); }
@Override public void afterTextChanged(Editable s) { Log.v("TextWatcher-afterTextChanged-->", s.toString() + "length" + s.length()); // 输入的时候,只有一个光标,那么这两个值应该是相等的。。。 editStart = et_user_ban.getSelectionStart(); editEnd = et_user_ban.getSelectionEnd(); // 限定EditText只能输入19个数字,并且达到19个的时候用红色显示 if (charSequence.length() > 19) { Toast.makeText(AddBankCardActivity.this, "你输入的字数已经超过了限制,不能再输入!", Toast.LENGTH_SHORT) .show(); // 默认光标在最前端,所以当输入第19个数字的时候,删掉(光标位置从11-1到11)的数字,这样就无法输入超过19个以后的数字 s.delete(editStart - 1, editEnd); // 当输入超过第19个数字的时候,改变字体颜色为红色 } }
private void initView() { mSessionEditText = (EditText) findViewById(R.id.et_sessionid); mUserIdEditText = (EditText) findViewById(R.id.et_userid); mRadioGroup = (RadioGroup) findViewById(R.id.rb_orientation); mStartBtn = (Button) findViewById(R.id.btnStart); mStartBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String sessionId = mSessionEditText.getText().toString().trim(); String userId = mUserIdEditText.getText().toString().trim(); if (TextUtils.isEmpty(sessionId)) { Toast.makeText(MyActivity.this, "pls input the sessionId!", Toast.LENGTH_SHORT) .show(); return; } int id = mRadioGroup.getCheckedRadioButtonId(); int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; if (id == R.id.rb_hor) { orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else if (id == R.id.rb_ver) orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; GameActivity.start(MyActivity.this, sessionId, userId, orientation); } }); String userId = String.valueOf((int) (Math.random() * 10 + 1)); mUserIdEditText.setText(userId); mHelper = ArcVoiceHelper.getInstance(getApplicationContext()); mHelper.init(ARC_APP_ID, ARC_APP_CREDENTIALS, ARC_REGION, userId); }
private void saveNote() { Log.d(TAG, "saveNote() called"); String title = titleEditText.getText().toString(); String body = bodyEditText.getText().toString(); if (title.isEmpty()) { if (!body.isEmpty()) { note.setTitle(body.substring(0, DEFAULT_TITLE_LENGTH)); } else { note.setTitle(PLACEHOLDER_TEXT_FOR_DATABASE); } } if (body.isEmpty()) { note.setBody(PLACEHOLDER_TEXT_FOR_DATABASE); } note.setTitle(title); note.setBody(body); if (noteExistsInDatabase == false) { Log.d(TAG, "Adding the following note: " + note.toString()); noteProvider.addNote(note); } else { Log.d(TAG, "Updating the following note: " + note.toString()); noteProvider.updateNote(note); } noteExistsInDatabase = true; }