Example usage for android.widget TextView getId

List of usage examples for android.widget TextView getId

Introduction

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

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java

void setupDaySelectionListeners(final View rootView) {

    View.OnClickListener listener = new View.OnClickListener() {
        @Override/*  ww  w.ja  v a 2 s  . co m*/
        public void onClick(View view) {

            TextView text = ((TextView) view);
            int index;
            switch (text.getId()) {
            case R.id.day_mo:
                schedule.toggleSelectedDay(0);
                index = 0;
                break;
            case R.id.day_tu:
                schedule.toggleSelectedDay(1);
                index = 1;
                break;
            case R.id.day_we:
                schedule.toggleSelectedDay(2);
                index = 2;
                break;
            case R.id.day_th:
                index = 3;
                schedule.toggleSelectedDay(3);
                break;
            case R.id.day_fr:
                schedule.toggleSelectedDay(4);
                index = 4;
                break;
            case R.id.day_sa:
                schedule.toggleSelectedDay(5);
                index = 5;
                break;
            case R.id.day_su:
                schedule.toggleSelectedDay(6);
                index = 6;
                break;
            default:
                return;
            }

            boolean daySelected = schedule.days()[index];
            StateListDrawable sld = (StateListDrawable) text.getBackground();
            GradientDrawable shape = (GradientDrawable) sld.getCurrent();
            shape.setColor(daySelected ? color : Color.WHITE);
            text.setTypeface(null, daySelected ? Typeface.BOLD : Typeface.NORMAL);
            text.setTextColor(daySelected ? Color.WHITE : Color.BLACK);

            boolean allDaysSelected = schedule.allDaysSelected();

            if (schedule.type() == Schedule.SCHEDULE_TYPE_EVERYDAY && !allDaysSelected) {
                setRepeatType(Schedule.SCHEDULE_TYPE_SOMEDAYS, rootView, false);
                ignoreNextEvent = true;
                repeatTypeSpinner.setSelection(1);
            } else if (schedule.type() == Schedule.SCHEDULE_TYPE_SOMEDAYS && allDaysSelected) {
                repeatTypeSpinner.setSelection(0);
                schedule.setType(Schedule.SCHEDULE_TYPE_EVERYDAY);
            }

            Log.d(TAG, "All days selected: " + allDaysSelected + ", repeatType: " + schedule.type());
        }
    };

    rootView.findViewById(R.id.day_mo).setOnClickListener(listener);
    rootView.findViewById(R.id.day_tu).setOnClickListener(listener);
    rootView.findViewById(R.id.day_we).setOnClickListener(listener);
    rootView.findViewById(R.id.day_th).setOnClickListener(listener);
    rootView.findViewById(R.id.day_fr).setOnClickListener(listener);
    rootView.findViewById(R.id.day_sa).setOnClickListener(listener);
    rootView.findViewById(R.id.day_su).setOnClickListener(listener);
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java

void setupDaySelectionListeners(final View rootView) {

    View.OnClickListener listener = new View.OnClickListener() {
        @Override/*  w ww .jav  a2 s.c  o  m*/
        public void onClick(View view) {

            TextView text = ((TextView) view);
            int index;
            switch (text.getId()) {
            case R.id.day_mo:
                schedule.toggleSelectedDay(0);
                index = 0;
                break;
            case R.id.day_tu:
                schedule.toggleSelectedDay(1);
                index = 1;
                break;
            case R.id.day_we:
                schedule.toggleSelectedDay(2);
                index = 2;
                break;
            case R.id.day_th:
                index = 3;
                schedule.toggleSelectedDay(3);
                break;
            case R.id.day_fr:
                schedule.toggleSelectedDay(4);
                index = 4;
                break;
            case R.id.day_sa:
                schedule.toggleSelectedDay(5);
                index = 5;
                break;
            case R.id.day_su:
                schedule.toggleSelectedDay(6);
                index = 6;
                break;
            default:
                return;
            }

            boolean daySelected = schedule.days()[index];

            if (!daySelected) {
                ((TextView) view).setTextAppearance(getActivity(), R.style.schedule_day_unselected);
                view.setBackgroundResource(R.drawable.dayselector_circle_unselected);
            } else {
                ((TextView) view).setTextAppearance(getActivity(), R.style.schedule_day_selected);
                view.setBackgroundResource(R.drawable.dayselector_circle);
            }

            boolean allDaysSelected = schedule.allDaysSelected();

            if (schedule.type() == Schedule.SCHEDULE_TYPE_EVERYDAY && !allDaysSelected) {
                setRepeatType(Schedule.SCHEDULE_TYPE_SOMEDAYS, rootView, false);
                ignoreNextEvent = true;
                repeatTypeSpinner.setSelection(1);
            } else if (schedule.type() == Schedule.SCHEDULE_TYPE_SOMEDAYS && allDaysSelected) {
                repeatTypeSpinner.setSelection(0);
                schedule.setType(Schedule.SCHEDULE_TYPE_EVERYDAY);
            }

            Log.d(TAG, "All days selected: " + allDaysSelected + ", repeatType: " + schedule.type());
        }
    };

    rootView.findViewById(R.id.day_mo).setOnClickListener(listener);
    rootView.findViewById(R.id.day_tu).setOnClickListener(listener);
    rootView.findViewById(R.id.day_we).setOnClickListener(listener);
    rootView.findViewById(R.id.day_th).setOnClickListener(listener);
    rootView.findViewById(R.id.day_fr).setOnClickListener(listener);
    rootView.findViewById(R.id.day_sa).setOnClickListener(listener);
    rootView.findViewById(R.id.day_su).setOnClickListener(listener);
}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

public static boolean clickOnBrickInAddBrickFragment(Solo solo, String brickName, boolean addToScript) {
    boolean success = false;
    int lowestIdTimeBeforeLast = -2;
    int lowestIdLastTime = -1;

    while (!success && lowestIdLastTime != lowestIdTimeBeforeLast) {

        lowestIdTimeBeforeLast = lowestIdLastTime;
        int farthestDownThisTime = -999999;
        int highestUpThisTime = 999999;

        ArrayList<TextView> array = solo.getCurrentViews(TextView.class);
        for (TextView candidate : array) {
            View greatGreatGrandParent = greatGreatGrandParent(candidate);
            if (greatGreatGrandParent != null
                    && greatGreatGrandParent.getId() == R.id.add_brick_fragment_list) {
                int bottom = getBottomOfBrickGivenViewInsideThatBrick(candidate);
                if (farthestDownThisTime < bottom) {
                    farthestDownThisTime = bottom;
                    lowestIdLastTime = candidate.getId();
                }/*from  ww  w.  j av a  2  s. c  o  m*/
                if (highestUpThisTime > bottom) {
                    highestUpThisTime = bottom;
                }
                if (candidate.getText().toString().equals(brickName)) {
                    solo.sleep(500);
                    solo.clickOnView(candidate);
                    success = true;
                    break;
                }
            }
        }

        if (!success) {
            int difference = farthestDownThisTime - highestUpThisTime;
            solo.drag(40, 40, difference * 0.75f, 40, DRAG_FRAMES);
        }
    }

    return success;
}

From source file:com.android.launcher3.Hotseat.java

void resetLayout() {
    mContent.removeAllViewsInLayout();//from w w  w . j a v  a 2  s  . c o  m

    if (!FeatureFlags.NO_ALL_APPS_ICON) {
        // Add the Apps button
        Context context = getContext();
        int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank();

        LayoutInflater inflater = LayoutInflater.from(context);
        TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mContent, false);
        Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

        mLauncher.resizeIconDrawable(d);
        int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
        Rect bounds = d.getBounds();
        d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx,
                bounds.bottom - scaleDownPx / 2);
        allAppsButton.setCompoundDrawables(null, d, null, null);

        allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
        allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
        if (mLauncher != null) {
            mLauncher.setAllAppsButton(allAppsButton);
            allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
            allAppsButton.setOnClickListener(mLauncher);
            allAppsButton.setOnLongClickListener(mLauncher);
            allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
        }

        // Note: We do this to ensure that the hotseat is always laid out in the orientation of
        // the hotseat in order regardless of which orientation they were added
        int x = getCellXFromOrder(allAppsButtonRank);
        int y = getCellYFromOrder(allAppsButtonRank);
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
        lp.canReorder = false;
        mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
    }
}

From source file:com.android.leanlauncher.Workspace.java

private void addAllAppsIcon() {
    // Add the Apps button
    LayoutInflater inflater = LayoutInflater.from(getContext());
    TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mWorkspace, false);
    Drawable d = getResources().getDrawable(R.drawable.all_apps_button_icon);
    Utilities.resizeIconDrawable(d);
    allAppsButton.setCompoundDrawables(null, d, null, null);
    allAppsButton.setContentDescription(getResources().getString(R.string.all_apps_button_label));

    mLauncher.setAllAppsButton(allAppsButton);

    allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    allAppsButton.setOnClickListener(mLauncher);
    CellLayout.LayoutParams lp = new CellLayout.LayoutParams((mWorkspace.getCountX() - 1) / 2,
            mWorkspace.getCountY() - 1, 1, 1);
    lp.canReorder = false;//  w ww  .jav a2s  .  c  om
    mWorkspace.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
}

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);/*from   w  w  w.  j  ava 2  s.  c o  m*/
    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);
    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();

}