List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:com.wholegroup.rally.ScoreActivity.java
/** * ? /*from w w w . ja v a2 s. co m*/ */ @Override protected Dialog onCreateDialog(int id) { final View textEntryView = View.inflate(this, R.layout.score_dialog, null); final TextView textName = (TextView) textEntryView.findViewById(R.id.score_dlg_username_edit); textName.setText(m_sName); return new AlertDialog.Builder(ScoreActivity.this).setView(textEntryView) .setTitle(getString(R.string.score_dialog_name)) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { m_sName = textName.getText().toString(); if (0 == m_sName.trim().length()) { m_sName = getString(R.string.score_default_name); } // ? ? ?? m_arrRecords[ScoreActivity.RECORDCOUNT - 1] = new ScoreRecord(m_sName, m_iScore, m_iType); // ? ?? Arrays.sort(m_arrRecords); // ?? ((ScoreAdapter) ScoreActivity.this.getListAdapter()).notifyDataSetChanged(); // ? SaveScore(); // , ? // ? getIntent().putExtra(getString(R.string.score_parameter_score), 0); } }).create(); }
From source file:com.example.wmgps.MainActivity.java
/** Called when the user clicks 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);*///from w w w . jav a 2 s . c om /*EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); TextView output = (TextView) findViewById(R.id.welcome); output.setText(message);*/ /*Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL)); startActivity(browserIntent); */ TextView hiddenText = (TextView) findViewById(R.id.Hidden11); if (Misc.isNullTrimmedString(hiddenText.getText().toString())) { TextView output = (TextView) findViewById(R.id.welcome1); boolean without_connection = true; Map<String, ArrayList<String>> typeAndValueOfTag = new LinkedHashMap<String, ArrayList<String>>(); // Insertion order must be followed String response = Misc.EMPTY_STRING; String welcome1String = "*******************Connected*************************"; try { response = new RetrieveFeedTask().execute(new String[] {}).get(); } catch (Exception e) { response = Misc.EMPTY_STRING; Log.e("Exception ", e.getMessage()); Log.e("Exception ", e.getLocalizedMessage()); Log.e("Exception ", e.getStackTrace().toString()); } if (Misc.isNullTrimmedString(response)) { // welcome1String = "***Loading Static, couldn't connect***"; response = "{\"window\":{\"elements\":[{\"type\":\"hidden\",\"name\":\"sourceAction\"},{\"type\":\"label\",\"value\":\"Warehouse Management\"}," + "{\"type\":\"break\"},{\"type\":\"label\",\"value\":\"--------- ----------\"},{\"type\":\"break\"}, {\"type\":\"label\",\"value\":\" User ID: \"}," + "{\"type\":\"entry\",\"name\":\"j_username\",\"value\":\"\",\"maxLength\":15,\"dispLength\":10," + "\"setHidden\":[{\"hiddenName\":\"sourceAction\",\"hiddenValue\":\"username\"}],\"focus\":true}," + "{\"type\":\"break\"},{\"type\":\"label\",\"value\":\"Password: \"}," + "{\"type\":\"entry\",\"name\":\"j_password\",\"value\":\"\",\"hideInput\":true,\"maxLength\":14,\"dispLength\":10,\"focus\":false}," + "{\"type\":\"keybinding\",\"value\":\"CTRL-X\",\"URL\":\"\",\"keyDescription\":\"CTRL-X Exit\"}," + "{\"type\":\"keybinding\",\"value\":\"CTRL-L\",\"URL\":\"/scopeRF/RFLogin/RFLegal.jsp\",\"keyDescription\":\"CTRL-L License Agreement\"}]" + ",\"submit\":\"/scopeRF/RFLogin/ProcessLogin.jsp\"}}"; } StringBuffer finalEncodedString = new StringBuffer(Misc.EMPTY_STRING); int currentOutputTag = R.id.Hidden1; int currentInputTag = R.id.edit_message; // Renderer::decodeConfig() if (!Misc.isNullTrimmedString(response)) { try { JSONObject jsonObj = new JSONObject(response); for (Iterator iterator = jsonObj.keys(); iterator.hasNext();) { String name = (String) iterator.next(); JSONObject jsonObj1 = jsonObj.getJSONObject(name); for (Iterator iterator1 = jsonObj1.keys(); iterator1.hasNext();) { String name1 = (String) iterator1.next(); if ("elements".equals(name1)) { JSONArray jsonArr = jsonObj1.getJSONArray(name1); boolean userName = false; boolean password = false; for (int i = 0; i < jsonArr.length(); i++) { JSONObject temp = jsonArr.getJSONObject(i); String initialValue = null; String initialName = null; String initialLabel = null; if (!temp.isNull("name") && temp.getString("name").equals("j_password")) { initialName = "j_password"; } else if (!temp.isNull("name") && temp.getString("name").equals("j_username")) { initialName = "j_username"; } for (Iterator iterator2 = temp.keys(); iterator2.hasNext();) { String tempName = (String) iterator2.next(); String tempValue = (String) temp.getString(tempName); if (tempName.equals("type")) { if (tempValue.equals("label") || tempValue.equals("entry")) { initialLabel = tempValue; } } else if (tempName.equals("value")) { initialValue = tempValue; } /* if(tempName.equals("label")) { if(Misc.isNullTrimmedString(initialValue)) initialLabel = tempName; else { typeAndValueOfTag.put("output",initialValue); initialValue = Misc.EMPTY_STRING; continue; } } else if(tempName.equals("value")) { if(Misc.isNullTrimmedString(initialName) && Misc.isNullTrimmedString(initialLabel)) { initialValue = tempValue; } else if(!Misc.isNullTrimmedString(initialLabel) && initialLabel.equals("label")) { typeAndValueOfTag.put("output",tempValue); initialValue = Misc.EMPTY_STRING; continue; } else if(!Misc.isNullTrimmedString(initialLabel) && initialLabel.equals("entry")) { if(!Misc.isNullTrimmedString(initialName) && initialName.equals("name")) typeAndValueOfTag.put("input",tempValue); else initialValue = tempValue; } } else if(tempName.equals("entry")) { if(Misc.isNullTrimmedString(initialValue) || Misc.isNullTrimmedString(initialLabel)) { initialName = tempName; } else typeAndValueOfTag.put("input",initialValue); finalEncodedString.append(" " + tempName + " " + tempValue + " ----- "); }*/ } if (initialLabel != null) { if (initialLabel.equals("label")) { if (initialValue.equals(" User ID: ")) { TextView output1 = (TextView) findViewById(R.id.userNameText); output1.setText(initialValue); output1.setVisibility(View.VISIBLE); userName = true; password = false; } else if (initialValue.equals("Password: ")) { TextView output1 = (TextView) findViewById(R.id.passwordText); output1.setText(initialValue); output1.setVisibility(View.VISIBLE); password = true; userName = false; } else { TextView output1 = (TextView) findViewById(currentOutputTag++); output1.setText(initialValue); output1.setVisibility(View.VISIBLE); userName = false; password = false; } } else if (initialLabel.equals("entry")) { if ("j_password".equals(initialName)) { EditText input = ((EditText) findViewById(R.id.passwordEdit)); input.setVisibility(View.VISIBLE); if (Misc.isNullTrimmedString(initialValue)) { input.setText(""); input.setHint("Please enter password"); } } else if ("j_username".equals(initialName)) { EditText input = ((EditText) findViewById(R.id.userNameEdit)); input.setVisibility(View.VISIBLE); if (Misc.isNullTrimmedString(initialValue)) { input.setText(""); input.setHint("Please enter username"); } } else { EditText input = ((EditText) findViewById(currentInputTag++)); input.setVisibility(View.VISIBLE); if (Misc.isNullTrimmedString(initialValue)) { input.setText(""); input.setHint("Please enter value"); } else input.setText(initialValue); } } } /*if(initialLabel != null) { List<String> listOfValues; if(typeAndValueOfTag.containsKey(initialLabel)) { listOfValues = typeAndValueOfTag.get(initialLabel); listOfValues.add(initialValue); } typeAndValueOfTag.put(initialLabel,initialValue); }*/ } } else { // Here, just the URL would get processed. So don't use. // output.setText(" " + name + " " + jsonObj1.getString(name1)); } } } TextView welcome1 = (TextView) findViewById(R.id.welcome1); welcome1.setText(welcome1String); // processUIDisplay(typeAndValueOfTag); /*if(finalEncodedString.length() == 0) finalEncodedString.append("Could not process"); output.setText(finalEncodedString.toString()); TextView output2 = (TextView) findViewById(R.id.Hidden1); output2.setText("Hidden one is enabled"); output2.setVisibility(View.VISIBLE);*/ } catch (JSONException e) { Log.e("Exception ", e.getMessage()); Log.e("Exception ", e.getLocalizedMessage()); Log.e("Exception ", e.getStackTrace().toString()); } } hiddenText.setText("validated user"); /* {"window":{"elements":[{"type":"hidden","name":"sourceAction"},{"type":"label","value":"Warehouse Management"}, {"type":"break"},{"type":"label","value":"--------- ----------"},{"type":"break"}, {"type":"label","value":" User ID: "}, {"type":"entry","name":"j_username","value":"","maxLength":15,"dispLength":10, "setHidden":[{"hiddenName":"sourceAction","hiddenValue":"username"}],"focus":true}, {"type":"break"},{"type":"label","value":"Password: "}, {"type":"entry","name":"j_password","value":"","hideInput":true,"maxLength":14,"dispLength":10,"focus":false}, {"type":"keybinding","value":"CTRL-X","URL":"","keyDescription":"CTRL-X Exit"}, {"type":"keybinding","value":"CTRL-L","URL":"/scopeRF/RFLogin/RFLegal.jsp","keyDescription":"CTRL-L License Agreement"}] ,"submit":"/scopeRF/RFLogin/ProcessLogin.jsp"}}*/ } else { List outputList = verifyUser(); if (!Misc.isNullList(outputList)) { String sessionId = (String) outputList.get(0); String userType = (String) outputList.get(1); Intent intent = new Intent(this, MenuActivity.class); if (!Misc.isNullTrimmedString(sessionId) && !Misc.isNullTrimmedString(userType) && Integer.parseInt(sessionId) > 0) { if (userType.equals(Constants.WORKER)) { MenuActivity.sessionId = Misc.EMPTY_STRING; TextView error = (TextView) findViewById(R.id.ErrorText); error.setText(Misc.EMPTY_STRING); error.setVisibility(View.GONE); intent.putExtra(Constants.USER_TYPE, Constants.WORKER); intent.putExtra(Constants.SESSION_ID, sessionId); } else { TextView error = (TextView) findViewById(R.id.ErrorText); error.setText(Misc.EMPTY_STRING); error.setVisibility(View.GONE); intent.putExtra(Constants.USER_TYPE, Constants.SUPERVISOR); intent.putExtra(Constants.SESSION_ID, sessionId); } } // goto Maps screen // Get the message from the intent startActivity(intent); } else { TextView error = (TextView) findViewById(R.id.ErrorText); error.setText("Invalid Username/Password"); error.setVisibility(View.VISIBLE); } } return; }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
public void handleRegisteredFbLogin(View v) throws ClientProtocolException, JSONException, IOException { TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); TextView errorMessage = (TextView) textEntryView.findViewById(R.id.errorMessage); String userName = fbUsername.getText().toString(), password = fbPassword.getText().toString(); Log.i(tag, "userName: " + userName + " ,password: " + password); mPhone = mPhoneEdit.getText().toString(); if (!Text.isEmail(userName)) { errorMessage.setText("Please enter a valid email"); fbUsername.requestFocus();/*from www . ja va 2 s.co m*/ return; } JSONObject response = new Cloud(getApplicationContext(), userName, password) .loginWithFacebook(countryCode + mPhone, fbId); Log.i(tag, "reponse: " + response); Log.i(tag, "message value: " + response.getString("message")); if (response.getString("message").trim().length() == 0) { mUsername = userName; mPassword = password; finishLogin(); } else { errorMessage.setText(response.getString("message")); } }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Invoked when the Reminder plugin is selected from the FindActivity menu. Used * here to retrieve the Find's lat, long, and date from the FindActivity view. * // w w w . j a v a2 s . c om * @param context, the calling Activity * @param find, the current Find * @param view, the FindActivity's content view * @param intent, the Intent that is passed to the menu activity */ public void menuItemSelectedCallback(Context context, Find find, View view, Intent intent) { Bundle bundle = new Bundle(); TextView tv = (TextView) view.findViewById(R.id.timeValueTextView); bundle.putString("Date", tv.getText().toString()); tv = (TextView) view.findViewById(R.id.longitudeValueTextView); bundle.putDouble("FindsLongitude", Double.parseDouble(tv.getText().toString())); tv = (TextView) view.findViewById(R.id.latitudeValueTextView); bundle.putDouble("FindsLatitude", Double.parseDouble(tv.getText().toString())); intent.putExtras(bundle); }
From source file:org.cocos2dx.lib.TextInputWraper.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (mMainView.getTextField() == v && isFullScreenEdit()) { // user press the action button, delete all old text and insert new text for (int i = mOriginText.length(); i > 0; --i) { mMainView.deleteBackward();/*from w ww. j a va2s.co m*/ LogD("deleteBackward"); } String text = v.getText().toString(); /* * If user input nothing, translate "\n" to engine. */ if (text.compareTo("") == 0) { text = "\n"; } if ('\n' != text.charAt(text.length() - 1)) { text += '\n'; } final String insertText = text; mMainView.insertText(insertText); LogD("insertText(" + insertText + ")"); } return false; }
From source file:com.amrutpatil.makeanote.NotesActivity.java
private void moveToTrash() { ContentValues contentValues = new ContentValues(); TextView title = (TextView) findViewById(R.id.title_note_custom_home); TextView description = (TextView) findViewById(R.id.description_note_custom_home); TextView dateTime = (TextView) findViewById(R.id.date_time_note_custom_home); contentValues.put(TrashContract.TrashColumns.TRASH_TITLE, title.getText().toString()); contentValues.put(TrashContract.TrashColumns.TRASH_DESCRIPTION, description.getText().toString()); contentValues.put(TrashContract.TrashColumns.TRASH_DATE_TIME, dateTime.getText().toString()); ContentResolver cr = this.getContentResolver(); Uri uri = TrashContract.URI_TABLE; cr.insert(uri, contentValues);// ww w.j a v a 2 s. c o m }
From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java
private void setTabText(MediaType mode, String text) { if (mTabTitles.size() == 1) { getActionBar().setTitle(text);//from w w w. jav a 2 s .c o m return; } TextView textView = null; for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { SlidingTabStrip v = (SlidingTabStrip) mSlidingTabLayout.getChildAt(0); Log.d("Media Chooser", v.getClass().getSimpleName()); //SlidingTabStrip currentTab = (SlidingTabStrip)v.getChildAt(i); TextView currentTextView = (TextView) v.getChildAt(i);//currentTab.findViewById(android.R.id.text1); String currentText = currentTextView.getText().toString(); if (mode == MediaType.IMAGE && currentText.startsWith(getResources().getString(R.string.image).trim())) { textView = currentTextView; break; } if (mode == MediaType.VIDEO && currentText.startsWith(getResources().getString(R.string.video).trim())) { textView = currentTextView; break; } } if (textView != null) { textView.setText(text); } }
From source file:com.evandroid.musica.fragment.LyricsViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);/*from w ww . java 2 s . c om*/ setHasOptionsMenu(true); View layout = inflater.inflate(R.layout.lyrics_view, container, false); if (savedInstanceState != null) try { Lyrics l = Lyrics.fromBytes(savedInstanceState.getByteArray("lyrics")); if (l != null) this.mLyrics = l; mSearchQuery = savedInstanceState.getString("searchQuery"); mSearchFocused = savedInstanceState.getBoolean("searchFocused"); } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } else { Bundle args = getArguments(); if (args != null) try { Lyrics lyrics = Lyrics.fromBytes(args.getByteArray("lyrics")); this.mLyrics = lyrics; if (lyrics != null && lyrics.getText() == null && lyrics.getArtist() != null) { String artist = lyrics.getArtist(); String track = lyrics.getTrack(); String url = lyrics.getURL(); fetchLyrics(artist, track, url); mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout); startRefreshAnimation(); } } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } } if (layout != null) { Bundle args = savedInstanceState != null ? savedInstanceState : getArguments(); boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean("pref_force_screen_on", false); TextSwitcher textSwitcher = (TextSwitcher) layout.findViewById(R.id.switcher); textSwitcher.setFactory(new LyricsTextFactory(layout.getContext())); ActionMode.Callback callback = new CustomSelectionCallback(getActivity()); ((TextView) textSwitcher.getChildAt(0)).setCustomSelectionActionModeCallback(callback); ((TextView) textSwitcher.getChildAt(1)).setCustomSelectionActionModeCallback(callback); textSwitcher.setKeepScreenOn(screenOn); layout.findViewById(R.id.lrc_view).setKeepScreenOn(screenOn); TextView id3TV = (TextView) layout.findViewById(R.id.id3_tv); SpannableString text = new SpannableString(id3TV.getText()); text.setSpan(new UnderlineSpan(), 1, text.length() - 1, 0); id3TV.setText(text); final RefreshIcon refreshFab = (RefreshIcon) getActivity().findViewById(R.id.refresh_fab); refreshFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mRefreshLayout.isRefreshing()) fetchCurrentLyrics(true); } }); FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class); startActivity(settingsIntent); } }); if (args != null) refreshFab.setEnabled(args.getBoolean("refreshFabEnabled", true)); mScrollView = (NestedScrollView) layout.findViewById(R.id.scrollview); mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout); TypedValue primaryColor = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true); mRefreshLayout.setColorSchemeResources(primaryColor.resourceId, R.color.accent); float offset = getResources().getDisplayMetrics().density * 64; mRefreshLayout.setProgressViewEndTarget(true, (int) offset); mRefreshLayout.setOnRefreshListener(this); if (mLyrics == null) { if (!startEmtpy) fetchCurrentLyrics(false); } else if (mLyrics.getFlag() == Lyrics.SEARCH_ITEM) { mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout); startRefreshAnimation(); if (mLyrics.getArtist() != null) fetchLyrics(mLyrics.getArtist(), mLyrics.getTrack()); } else //Rotation, resume update(mLyrics, layout, false); } if (broadcastReceiver == null) broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { searchResultLock = false; String artist = intent.getStringExtra("artist"); String track = intent.getStringExtra("track"); if (artist != null && track != null && mRefreshLayout.isEnabled()) { startRefreshAnimation(); new ParseTask(LyricsViewFragment.this, false, true).execute(mLyrics); } } }; return layout; }
From source file:gr.scify.newsum.ui.SearchViewActivity.java
private void Copy() { // TextView tx = (TextView) findViewById(R.id.textView1); TextView title = (TextView) findViewById(R.id.title); String sdtitle = title.getText().toString(); // String copytext = tx.getText().toString(); String alphaAndDigits = sdtitle.replaceAll("[^\\p{L}\\p{N}]", " "); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); // track the copy to SD button if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Save to SD", alphaAndDigits, 0l); }//from w ww.java 2 s. c o m if (isSDPresent) { File folder = new File(Environment.getExternalStorageDirectory() + "/NewSum"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { // Do something on success } else { // Do something else on failure } File logFile = new File(folder, alphaAndDigits + ".txt"); // File logFile = new // File(Environment.getExternalStorageDirectory().toString(), // alphaAndDigits+".txt"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } BufferedWriter output = null; try { output = new BufferedWriter(new FileWriter(logFile)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.write(pText); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { output.close(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.save_massage); builder.setMessage(logFile.getPath()); builder.setPositiveButton(getResources().getText(R.string.ok).toString(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog a = builder.create(); a.show(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast.makeText(SearchViewActivity.this, R.string.check_sd, Toast.LENGTH_SHORT).show(); } }