Example usage for android.widget TextView getText

List of usage examples for android.widget TextView getText

Introduction

In this page you can find the example usage for android.widget TextView getText.

Prototype

@ViewDebug.CapturedViewProperty
public CharSequence getText() 

Source Link

Document

Return the text that TextView is displaying.

Usage

From source file:android.hawkencompanionapp.activities.UserAccountMainActivity.java

private void onNavDrawerItemClick(View view) {
    final TextView navItem = (TextView) view;
    final String navItemStr = navItem.getText().toString();
    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
    final Fragment selectedFragment = mFragmentMap.get(navItemStr);

    if (selectedFragment == null) {
        displayUIToast("Need to implement");
    } else if (selectedFragment instanceof UserAccountFragment) {

        if (mUserAccountBundle == null) { //User hasn't logged in
            displayUIToast("Please login");
            finish();/* ww  w. j a  v  a 2  s .  c o  m*/
        } else {
            //Only pass the account details to fragments that actually need it
            mUserAccountBundle.putString(FRAGMENT_TITLE_BUNDLE_KEY, navItemStr);
            swapCurrentFragment(selectedFragment, mUserAccountBundle);
        }

    } else {
        final Bundle b = new Bundle();
        b.putString(FRAGMENT_TITLE_BUNDLE_KEY, navItemStr);
        swapCurrentFragment(selectedFragment, b);
    }

    //Close the navigation drawer
    drawerLayout.closeDrawers();
}

From source file:can.yrt.onebusaway.MyStopListFragmentBase.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    final TextView text = (TextView) info.targetView.findViewById(R.id.stop_name);
    menu.setHeaderTitle(text.getText());
    if (isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_create_shortcut);
    } else {// w ww  .j  a  v  a 2 s.c  o m
        menu.add(0, CONTEXT_MENU_DEFAULT, 0, R.string.my_context_get_stop_info);
    }
    menu.add(0, CONTEXT_MENU_SHOW_ON_MAP, 0, R.string.my_context_showonmap);
    if (!isShortcutMode()) {
        menu.add(0, CONTEXT_MENU_CREATE_SHORTCUT, 0, R.string.my_context_create_shortcut);
    }
}

From source file:company.test.Test.java

public void onDoneButtonClick(View view) {
    View v = (View) view.getParent();
    TextView taskTextView = (TextView) v.findViewById(R.id.taskTextView);
    String task = taskTextView.getText().toString();

    String sql = String.format("DELETE FROM %s WHERE %s = '%s'", ItemContract.TABLE, ItemContract.Columns.ITEM,
            task);// w  ww .jav a2  s.c  om

    SQLiteDatabase sqlDB = helper.getWritableDatabase();
    sqlDB.execSQL(sql);
    updateUI();
    retrieveGl();
}

From source file:com.loadsensing.app.LlistaXarxesActivity.java

protected void onListItemClick(ListView l, View v, int position, long id) {
    // obtenim el valor de la xarxa amb el camp ocult text6 del layout i obrim la nova pantalla de llistat de sensors
    TextView c = (TextView) v.findViewById(R.id.text6);
    String idxarxaselected = c.getText().toString();

    Intent intent = new Intent();
    intent.setClass(this.getApplicationContext(), SensorsActivity.class);
    intent.putExtra("idxarxaselected", idxarxaselected);
    startActivity(intent);/*from  w  w  w .  j a v  a 2s  .  c  o m*/

}

From source file:com.example.spoilerfreehighlights.MainActivity.java

public void showHighlights(View view) {
    TextView highlights = (TextView) view.findViewById(R.id.highlights);
    if (highlights.getText() != null) {

        String url = highlights.getText().toString();
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        startActivity(browserIntent);/*from ww w.ja v a  2  s. c o  m*/
    }
}

From source file:ca.ualberta.cmput301.t03.user.EditProfileFragment.java

/**
 * Callback after model data has been fetched.
 *
 * Populates the EditText fields with values from the model
 * once the data has been fetched, and sets up an
 * OnFocusChangeListener to update the model for new input.
 *
 *//*from ww  w . j  a v a 2 s . c  om*/
public void populateFields() {
    mNameField.setText(user.getUsername());
    mCityField.setText(model.getCity());
    mEmailField.setText(model.getEmail());
    mPhoneField.setText(model.getPhone());

    mEmailField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                TextView t = (TextView) v;
                if (controller.isEmailInValid(t.getText().toString())) {
                    Snackbar.make(getView(), "Invalid email!", Snackbar.LENGTH_SHORT).show();
                    t.setText("");
                }
            }
        }
    });

    mCityField.addTextChangedListener(controller.getCityWatcher());
    mPhoneField.addTextChangedListener(controller.getPhoneWatcher());
    mEmailField.addTextChangedListener(controller.getEmailWatcher());
}

From source file:com.example.android.animationsdemo.ListViewDraggingAnimation.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        TextView tv = (TextView) listView.getChildAt(0);
        Log.v("settingspage", "Text from textview" + tv.getText());
        int k = listView.getCount();
        Log.v("settingspage", "Number of views" + String.valueOf(k));
        String[] libraries = new String[k];
        for (int i = 0; i < k; i++) {
            tv = (TextView) listView.getChildAt(i);
            libraries[i] = (String) tv.getText();
            Log.v("settingspage", "valueoflib" + libraries[i]);
            SharedPreferences settings3 = getApplicationContext()
                    .getSharedPreferences("com.example.android.animationsdemo", 0);
            SharedPreferences.Editor editor3 = settings3.edit();
            editor3.putString(String.valueOf(i), libraries[i]);
            editor3.putString(libraries[i] + "new", String.valueOf(i));

            editor3.apply();//from  www  .  jav a2 s.  c  om
        }
        Intent i = new Intent(ListViewDraggingAnimation.this, ScreenSlideActivity.class);
        startActivity(i);
        finish();
    }
    return false;
}

From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java

/**
 * Method that adds or removes a strike from a TextView object
 *
 * @param textView The textView to manage
 *//*from  w  w  w .ja v a 2  s .  c  om*/
private final void addOrRemoveStrikeTextView(TextView textView, boolean toAdd) {
    textView.setText(textView.getText().toString(), TextView.BufferType.SPANNABLE);
    final Spannable spannable = (Spannable) textView.getText();

    if (toAdd == true) {
        // Add a StrikethroughSpan style
        final StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
        spannable.setSpan(strikethroughSpan, 0, textView.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        // Remove only StrikethroughSpan style
        final Object spans[] = spannable.getSpans(0, textView.length(), Object.class);
        for (final Object span : spans) {
            if (span instanceof StrikethroughSpan == true) {
                spannable.removeSpan(span);
                return;
            }
        }
    }
}

From source file:com.example.android.animationsdemo.ListViewDraggingAnimation.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.home: {
        TextView tv = (TextView) listView.getChildAt(0);
        Log.v("settingspage", "Text from textview" + tv.getText());
        int k = listView.getCount();
        Log.v("settingspage", "Number of views" + String.valueOf(k));
        String[] libraries = new String[k];
        for (int i = 0; i < k; i++) {
            tv = (TextView) listView.getChildAt(i);
            libraries[i] = (String) tv.getText();
            Log.v("settingspage", "valueoflib" + libraries[i]);
            SharedPreferences settings3 = getApplicationContext()
                    .getSharedPreferences("com.example.android.animationsdemo", 0);
            SharedPreferences.Editor editor3 = settings3.edit();
            editor3.putString(String.valueOf(i), libraries[i]);
            editor3.putString(libraries[i] + "new", String.valueOf(i));

            editor3.apply();//w ww. j a v a 2s .c  om
        }
        Intent i = new Intent(ListViewDraggingAnimation.this, ScreenSlideActivity.class);
        startActivity(i);
        finish();
    }
    case R.id.refresh: {
        Intent i = new Intent(ListViewDraggingAnimation.this, ScreenSlideActivity.class);
        startActivity(i);
        finish();
    }

    default:
        return true;
    }

}

From source file:com.appmanager.parimal.activity.MainActivity.java

@Override
public void onDrawerItemSelected(View view, int position) {
    TextView mView = (TextView) view.findViewById(R.id.title);
    displayView(mView.getText().toString(), position);
}