Example usage for android.widget TextView setText

List of usage examples for android.widget TextView setText

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setText(@StringRes int resid) 

Source Link

Document

Sets the text to be displayed using a string resource identifier.

Usage

From source file:com.privacity.PerfilActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_perfil_view);
    com = new ConexionSiabra(this);

    descripcion = this.getIntent().getStringExtra("descripcion");
    codigo = this.getIntent().getStringExtra("codigo");
    usuario = this.getIntent().getStringExtra("usuario");
    permisos = this.getIntent().getStringExtra("permisos");
    agregado = this.getIntent().getStringExtra("agregado");
    botonCancelar = findViewById(R.id.cancelarBtt);
    botonAceptar = findViewById(R.id.aceptarBtt);
    //Hacemos invisible los botones que no queremos utilizar.
    if (agregado.equals("True"))
        botonCancelar.setVisibility(View.VISIBLE);
    else/*w ww.j a  v  a 2  s .  c o m*/
        botonAceptar.setVisibility(View.VISIBLE);

    TextView txtUsuario = (TextView) findViewById(R.id.autorTxt);
    txtUsuario.setText(usuario);
    TextView txtCodigo = (TextView) findViewById(R.id.codigoTxt);
    txtCodigo.setText(codigo);
    TextView txtDescripcion = (TextView) findViewById(R.id.descripcionTxt);
    txtDescripcion.setText(descripcion);
    TextView txtPermisos = (TextView) findViewById(R.id.permisosTxt);
    // txtPermisos.setText(permisosToString());
    txtPermisos.setText(permisosToReadable());
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
    }
}

From source file:at.alladin.rmbt.android.fragments.result.QoSCategoryPagerFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
    tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
    tabHost.setup();//from w w  w  . j a  v a  2 s.c  om
    tabHost.setOnTabChangedListener(this);

    for (int i = 0; i < pagerAdapter.getCount(); i++) {
        TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
        //tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
        tab.setContent(android.R.id.tabcontent);

        View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
        TextView title = (TextView) indicator.findViewById(android.R.id.title);
        title.setText(pagerAdapter.getPageTitle(i));
        tab.setIndicator(indicator);
        tabHost.addTab(tab);
    }

    viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);

    viewPager.setOnPageChangeListener(this);
    setCurrentPosition(0);

    scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);

    if (initPosition != null) {
        viewPager.setCurrentItem(initPosition);
    }

    return v;
}

From source file:com.miuidev.themebrowser.MainActivity.java

private void displayAbout() {
    AlertDialog.Builder builder;/*from  w  w  w.  ja  v  a  2 s  .  co  m*/
    AlertDialog alertDialog;

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.dialog_about,
            (ViewGroup) findViewById(R.id.DialogAboutRelativeLayout));

    TextView text = (TextView) layout.findViewById(R.id.AboutVersionValue);
    text.setText(getVersionName());

    builder = new AlertDialog.Builder(this);
    builder.setView(layout);
    builder.setCancelable(false).setPositiveButton(getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });
    alertDialog = builder.create();
    alertDialog.show();

}

From source file:com.android.browser.GearsPermissionsDialog.java

public void setup() {
    inflate(R.layout.gears_dialog_permission, R.id.panel_content);
    setupButtons(R.string.permission_button_alwaysdeny, R.string.permission_button_allow,
            R.string.permission_button_deny);

    try {//from  ww w .  j  av  a2  s.c  om
        JSONObject json = new JSONObject(mDialogArguments);

        if (json.has("dialogType")) {
            mDialogType = json.getString("dialogType");
            setupDialog();
        }

        if (!json.has("customName")) {
            setLabel(json, "origin", R.id.origin_title);
            View titleView = findViewById(R.id.origin_title);
            if (titleView != null) {
                TextView title = (TextView) titleView;
                title.setGravity(Gravity.CENTER);
            }
        } else {
            setLabel(json, "customName", R.id.origin_title);
            setLabel(json, "origin", R.id.origin_subtitle);
            setLabel(json, "customMessage", R.id.origin_message);
        }

        if (json.has("customIcon")) {
            String iconUrl = json.getString("customIcon");
            mChoosenIconSize = 32;
            downloadIcon(iconUrl);
        }

        View msg = findViewById(R.id.permission_dialog_message);
        if (msg != null) {
            TextView dialogMessage = (TextView) msg;
            if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
                dialogMessage.setText(R.string.query_data_message);
            } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
                dialogMessage.setText(R.string.location_message);
            }
        }

    } catch (JSONException e) {
        Log.e(TAG, "JSON exception ", e);
    }
}

From source file:com.andclient.SetupConnectionActivity.java

private void saveSettingsOnClick(View v) {
    int keyboardPort = 0, mousePort = 0;

    EditText et = (EditText) findViewById(R.id.editTextServerIP);
    String ip = et.getText().toString();
    boolean correctIp = InetAddressUtils.isIPv4Address(ip);
    if (!correctIp) {
        Toast.makeText(SetupConnectionActivity.this, "Server IP is not a correct IPv4 address",
                Toast.LENGTH_SHORT).show();
    }/*from  w  w  w. jav  a 2  s  . co  m*/

    et = (EditText) findViewById(R.id.editTextMousePort);
    String txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            mousePort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port is not a number", Toast.LENGTH_SHORT)
                    .show();
        }
        if (mousePort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    et = (EditText) findViewById(R.id.editTextKeyboardPort);
    txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            keyboardPort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be an integer", Toast.LENGTH_SHORT)
                    .show();
        }
        if (keyboardPort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (correctIp && mousePort > 0 && keyboardPort > 0) {
        SharedPreferences.Editor editor = mSettings.edit();
        editor.putString(StartActivity.PREF_SERVER_IP, ip).putInt(StartActivity.PREF_MOUSE_PORT, mousePort)
                .putInt(StartActivity.PREF_KEYBOARD_PORT, keyboardPort);

        editor.commit();
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setTextColor(Color.GREEN);
        tv.setText("Settings saved.");
        tv.setVisibility(View.VISIBLE);
    } else {
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setText("Incorrect input data.");
        tv.setTextColor(Color.RED);
        tv.setVisibility(View.VISIBLE);
    }
}

From source file:com.ibm.mobileclientaccess.fbauth.MainActivity.java

@Override
public void onSuccess(Response response) {
    setStatus("Connected to Facebook - OK");

    final TextView viewById = (TextView) findViewById(R.id.user);
    runOnUiThread(new Runnable() {
        @Override//from w  ww. j a va  2 s . com
        public void run() {
            viewById.setText(
                    "User: " + MCAAuthorizationManager.getInstance().getUserIdentity().getDisplayName());
        }
    });
}

From source file:com.textuality.gpstats.GPlusSnowflake.java

private void barf(Response response) {
    TextView tv = (TextView) findViewById(R.id.output);
    String b = new String(response.body);
    Log.d(AuthorizedActivity.TAG, "Error " + response.status + " body: " + b);
    tv.setText("OUCH!  The Internet never works!\n" + b);
}

From source file:net.idlesoft.android.apps.github.activities.CommitsList.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.commits_list);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(CommitsList.this, Search.class));
        }/*from   w  w w  . j a  va 2s . co  m*/
    });

    final TextView title = (TextView) findViewById(R.id.tv_page_title);
    title.setText("Recent Commits");

    mCommitListView = (ListView) findViewById(R.id.lv_commits_list_list);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepoName = extras.getString("repo_name");
        mRepoOwner = extras.getString("repo_owner");
        mBranchName = extras.getString("branch_name");
    }
}

From source file:com.mappn.gfan.common.util.Utils.java

/**
 * Search Tab??TextViewView/*from  ww w.  j av a  2  s . c  o  m*/
 */
public static View createSearchTabView(Context context, String text) {
    TextView view = (TextView) LayoutInflater.from(context).inflate(R.layout.common_tab_view, null);
    view.setBackgroundResource(R.drawable.search_tab_selector);
    view.setTextAppearance(context, R.style.search_tab_text);
    view.setText(text);
    return view;
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.PhoneProfileFragment.java

private void callPhone(final String number) {
    (new AsyncTask<Void, Void, DConnectMessage>() {
        public DConnectMessage doInBackground(final Void... args) {

            try {
                URIBuilder builder = new URIBuilder();
                builder.setProfile(PhoneProfileConstants.PROFILE_NAME);
                builder.setAttribute(PhoneProfileConstants.ATTRIBUTE_CALL);
                builder.addParameter(DConnectMessage.EXTRA_DEVICE_ID, getSmartDevice().getId());
                builder.addParameter(PhoneProfileConstants.PARAM_PHONE_NUMBER, number);
                builder.addParameter(DConnectMessage.EXTRA_ACCESS_TOKEN, getAccessToken());

                HttpResponse response = getDConnectClient().execute(getDefaultHost(),
                        new HttpPost(builder.build()));
                return (new HttpMessageFactory()).newDConnectMessage(response);
            } catch (URISyntaxException e) {
                e.printStackTrace();//www. j  a v  a 2  s  .co m
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(final DConnectMessage result) {
            if (getActivity().isFinishing()) {
                return;
            }

            TextView tv = (TextView) getView().findViewById(R.id.fragment_phone_result);
            if (result == null) {
                tv.setText("failed");
            } else {
                tv.setText(result.toString());
            }
        }
    }).execute();
}