Example usage for android.widget TextView setId

List of usage examples for android.widget TextView setId

Introduction

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

Prototype

public void setId(@IdRes int id) 

Source Link

Document

Sets the identifier for this view.

Usage

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptVNCAllowExternal(final Activity activity) {
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Enable VNC server");

    TextView textView = new TextView(activity);
    textView.setVisibility(View.VISIBLE);
    textView.setId(201012010);
    textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n"
            + "Warning: VNC is not secure make sure you're on a private network!\n");

    EditText passwdView = new EditText(activity);
    passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwdView.setHint("Password");
    passwdView.setEnabled(true);//from  w  w w  .  java2  s. c om
    passwdView.setVisibility(View.VISIBLE);
    passwdView.setId(11111);
    passwdView.setSingleLine();

    RelativeLayout mLayout = new RelativeLayout(this);
    mLayout.setId(12222);

    RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId());
    mLayout.addView(textView, textViewParams);

    RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId());
    // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,
    // mLayout.getId());
    mLayout.addView(passwdView, passwordViewParams);

    alertDialog.setView(mLayout);

    final Handler handler = this.handler;

    alertDialog.setButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(11111);

            if (a.getText().toString().trim().equals("")) {
                Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show();
                vnc_passwd = null;
                vnc_allow_external = 0;
                mVNCAllowExternal.setChecked(false);
                // LimboSettingsManager.setVNCAllowExternal(activity, false);
                return;
            } else {
                sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd");
                vnc_passwd = a.getText().toString();
                vnc_allow_external = 1;
                // LimboSettingsManager.setVNCAllowExternal(activity, true);
            }

        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            vnc_passwd = null;
            vnc_allow_external = 0;
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mVNCAllowExternal.setChecked(false);
            // LimboSettingsManager.setVNCAllowExternal(activity, false);
            vnc_passwd = null;
            vnc_allow_external = 0;
        }
    });
    alertDialog.show();

}

From source file:com.skytree.epubtest.BookViewActivity.java

public TextView makeLabel(int id, String text, int gravity, float textSize, int textColor) {
    TextView label = new TextView(this);
    label.setId(id);
    label.setGravity(gravity);//  w  w w.j  a  v  a  2 s .co  m
    label.setBackgroundColor(Color.TRANSPARENT);
    label.setText(text);
    label.setTextColor(textColor);
    label.setTextSize(textSize);
    return label;
}