Java Code Examples for android.widget.TextView#getId()

The following examples show how to use android.widget.TextView#getId() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        switch (v.getId()) {
            case R.id.target_temp_tool0_input:
                setTargetTempTool0();
                break;
            case R.id.offset_temp_tool0_input:
                setOffsetTempTool0();
                break;
            case R.id.target_temp_tool1_input:
                setTargetTempTool1();
                break;
            case R.id.offset_temp_tool1_input:
                setOffsetTempTool1();
                break;
            case R.id.target_temp_bed_input:
                setTargetTempBed();
                break;
            case R.id.offset_temp_bed_input:
                setOffsetTempBed();
                break;
        }
    }
    return false;
}
 
Example 2
@Override
public void onClick(View v) {
  if (v.getId() == R.id.next) {
    mListener.onOptionSelected();
    return;
  }
  for (TextView t : options) {
    if (t.getId() == v.getId()) {
      AppSettings settings = AppSettings.getInstance(getActivity());
      settings.setCalcMethodFor(mParam1, Integer.valueOf((String) t.getTag()));
      t.setSelected(true);
      mListener.onOptionSelected();
    } else {
      t.setSelected(false);
    }
  }
}
 
Example 3
@Override
public void onClick(View v) {
  if (v.getId() == R.id.next) {
    mListener.onOptionSelected();

  } else if (v.getId() == R.id.prev) {
    getActivity().onBackPressed();

  } else {
    for (int i=0; i < views.length; i++) {
      TextView tv = views[i];
      if (tv.getId() == v.getId()) {
        tv.setSelected(true);
        AppSettings.getInstance(getActivity()).setHighLatitudeAdjustmentMethodFor(mParam1, i);
      } else {
        tv.setSelected(false);
      }
    }
    mListener.onOptionSelected();
  }

}
 
Example 4
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (getView() == null || actionId != EditorInfo.IME_ACTION_DONE) {
        return false;
    }
    switch (v.getId()) {
        case R.id.service_name:
            regTypeEditText.requestFocus();
            return true;
        case R.id.reg_type:
            portEditText.requestFocus();
            return true;
        case R.id.port:
            InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
            return true;
    }
    return false;
}
 
Example 5
Source Project: adapter-kit   File: InstantAdapterCore.java    License: Apache License 2.0 6 votes vote down vote up
private void updateTextView(final Holder holder, final Object returnValue) {
    InstantText instantText = (InstantText) holder.meta.annotation;
    TextView textView = (TextView) holder.view;
    int viewId = textView.getId();

    String text = null;
    if (returnValue != null) {
        text = applyDatePattern(viewId, instantText, returnValue);
        text = applyFormatString(viewId, instantText, text, returnValue);
        if (text == null) {
            text = returnValue.toString();
        }
    }

    textView.setText(instantText.isHtml() ? Html.fromHtml(text) : text);
}
 
Example 6
Source Project: EosCommander   File: PushFragment.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    if (EditorInfo.IME_ACTION_SEND == actionId) {
        onPushAction();
        return true;
    }
    else
    if ( (EditorInfo.IME_ACTION_SEARCH == actionId ) && ( textView.getId() == R.id.et_contract_account) ){
        onContractEntered( mEtContract.getText().toString());
    }

    return false;
}
 
Example 7
@OnClick({R.id.shot_count, R.id.followers_count, R.id.likes_count})
void playerActionClick(TextView view) {
    ((AnimatedVectorDrawable) view.getCompoundDrawables()[1]).start();
    switch (view.getId()) {
        case R.id.followers_count:
            PlayerSheet.start(PlayerActivity.this, player);
            break;
    }
}
 
Example 8
private void clipboard(TextView tv) {
    // which view are we copying to the clipboard?
    int which;

    switch (tv.getId()) {
        case txt_request_url: // the url field
            which = code_snippet;
            break;

        case txt_response_body: // the response body
            which = raw_object;
            break;

        default:
            which = UNSET; // don't assign a prefix
    }

    // if we know which view we're copying, prefix it with useful info
    String what = which == UNSET ? "" : getString(which) + " ";

    // concat the clipboard data to this String
    what += getString(clippy);

    // inform the user that data was added to the clipboard
    Toast.makeText(
            getActivity(),
            what,
            Toast.LENGTH_SHORT
    ).show();

    // depending on our API, do it one way or another...
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // old way
        ClipboardManager clipboardManager = (ClipboardManager)
                getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setText(tv.getText());
    } else {
        clipboard11(tv);
    }
}
 
Example 9
private void clipboard(TextView tv) {
    int which;
    switch (tv.getId()) {
        case txt_request_url:
            which = req_url;
            break;
        case txt_response_headers:
            which = response_headers;
            break;
        case txt_response_body:
            which = response_body;
            break;
        default:
            which = UNSET;
    }
    String what = which == UNSET ? "" : getString(which) + " ";
    what += getString(clippy);
    Toast.makeText(getActivity(), what, Toast.LENGTH_SHORT).show();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // old way
        ClipboardManager clipboardManager = (ClipboardManager)
                getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setText(tv.getText());
    } else {
        clipboard11(tv);
    }
}
 
Example 10
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {
    // Only handle "Done" action triggered by the user tapping "Enter" on the keyboard.
    if (actionId != EditorInfo.IME_ACTION_DONE) {
        return false;
    }

    int textViewId = textView.getId();
    if (textViewId == R.id.fps_edittext) {
        setFrameRate(textView);
    } else if (textViewId == R.id.step_edittext) {
        setStepSize(textView);
    }
    return false;
}
 
Example 11
Source Project: ShakeDetector   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void updateSeekBarLabel(TextView view, String textToAppend) {
    String label = "";
    if (view.getId() == R.id.sensibility_label) {
        label = getString(R.string.label_sensibility, textToAppend);
    }
    if (view.getId() == R.id.shake_number_label) {
        label = getString(R.string.label_shake_number, textToAppend);
    }
    view.setText(label);
}
 
Example 12
Source Project: screenplay   File: NavigationMenuView.java    License: MIT License 5 votes vote down vote up
private void setSelected(int id) {
    selected = id;
    for (int i = 0; i < getChildCount(); i++) {
        TextView child = (TextView) getChildAt(i);
        if (id == child.getId()) {
            child.setSelected(true);
        } else {
            child.setSelected(false);
        }
    }
}
 
Example 13
private static ArrayList<String> extractTextFromNotification(Service service, RemoteViews view) {
  	LayoutInflater inflater = (LayoutInflater) service.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   ArrayList<String> result = new ArrayList<String>();
   if (view == null) {
   	Log.d(TAG, "View is empty");
   	return null;
   }
try {
	int layoutid = view.getLayoutId();
	ViewGroup localView = (ViewGroup) inflater.inflate(layoutid, null);
    view.reapply(service.getApplicationContext(), localView);
    ArrayList<View> outViews = new ArrayList<View>();
    extractViewType(outViews, TextView.class, localView);
    for (View  ttv: outViews) {
    	TextView tv = (TextView) ttv;
    	String txt = tv.getText().toString();
    	if (!TextUtils.isEmpty(txt) && tv.getId() != TIMESTAMPID) {
    		result.add(txt);
    	}
	}
} catch (Exception e) {
	Log.d(TAG, "FAILED to load notification " + e.toString());
	Log.wtf(TAG, e);
	return null;
	//notification might have dissapeared by now
}
Log.d(TAG, "Return result" + result);
   return result;
  }
 
Example 14
void updateFlowLayout(RecurrenceOption recurrenceOption) {
    // Currently selected recurrence option
    int viewIdToSelect;

    switch (recurrenceOption) {
        case DOES_NOT_REPEAT:
            viewIdToSelect = R.id.tvDoesNotRepeat;
            break;
        case DAILY:
            viewIdToSelect = R.id.tvDaily;
            break;
        case WEEKLY:
            viewIdToSelect = R.id.tvWeekly;
            break;
        case MONTHLY:
            viewIdToSelect = R.id.tvMonthly;
            break;
        case YEARLY:
            viewIdToSelect = R.id.tvYearly;
            break;
        case CUSTOM:
            viewIdToSelect = R.id.tvChosenCustomOption;
            break;
        default:
            viewIdToSelect = R.id.tvDoesNotRepeat;
    }

    for (TextView tv : mRepeatOptionTextViews) {
        tv.setOnClickListener(this);

        // If we have a non-empty recurrence rule,
        // display it for easy re-selection
        if (tv.getId() == R.id.tvChosenCustomOption) {
            if (!TextUtils.isEmpty(mRecurrenceRule)) {
                EventRecurrence eventRecurrence = new EventRecurrence();
                eventRecurrence.parse(mRecurrenceRule);
                Time startDate = new Time(TimeZone.getDefault().getID());
                startDate.set(mCurrentlyChosenTime);
                eventRecurrence.setStartDate(startDate);

                tv.setVisibility(View.VISIBLE);

                tv.setText(EventRecurrenceFormatter.getRepeatString(
                        getContext(), getContext().getResources(),
                        eventRecurrence, true));
            } else { // hide this TextView since 'mRecurrenceRule' is not available
                tv.setVisibility(View.GONE);
                continue;
            }
        }

        // Selected option
        if (tv.getId() == viewIdToSelect) {
            // Set checkmark drawable & drawable-padding
            tv.setCompoundDrawablesWithIntrinsicBounds(null, null,
                    mCheckmarkDrawable, null);
            tv.setCompoundDrawablePadding(mSelectedOptionDrawablePadding);
            tv.setTextColor(mSelectedStateTextColor);

            continue;
        }

        // Unselected options
        tv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        tv.setTextColor(mUnselectedStateTextColor);
    }
}
 
Example 15
private void clipboard(TextView tv) {
    // which view are we copying to the clipboard?
    int which;

    switch (tv.getId()) {
        case txt_request_url: // the url field
            which = req_url;
            break;

        case txt_response_headers: // the display headers
            which = response_headers;
            break;

        case txt_response_body: // the response body
            which = response_body;
            break;

        default:
            which = UNSET; // don't assign a prefix
    }

    // if we know which view we're copying, prefix it with useful info
    String what = which == UNSET ? "" : getString(which) + " ";

    // concat the clipboard data to this String
    what += getString(clippy);

    // inform the user that data was added to the clipboard
    Toast.makeText(
            getActivity(),
            what,
            Toast.LENGTH_SHORT
    ).show();

    // depending on our API, do it one way or another...
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // old way
        ClipboardManager clipboardManager = (ClipboardManager)
                getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setText(tv.getText());
    } else {
        clipboard11(tv);
    }
}
 
Example 16
Source Project: FixMath   File: PlayActivity.java    License: Apache License 2.0 2 votes vote down vote up
public void CalcClick(View view){
    clicked = true;
    isKeyboradOpen = true;
    ClickOn = view.getId();
    //FIELD TO CLOSE KEYBORAD
    CloseKeyboardNextTo();

    //FIGURE ANIMATION


    animClickFigures(view.getTag().toString());



    //      KEYBOARD
    RelativeLayout keyobard1 = (RelativeLayout)findViewById(R.id.keyboard);
    View key = findViewById(R.id.keyboard);
    setClickableRecursive(key, true);

    //Keyboard animation
    SameLineKeyAnim(view);

    RelativeLayout.LayoutParams keyboardParams = (RelativeLayout.LayoutParams)keyobard1.getLayoutParams();

    //RESET KEYBOARD
    keyboardParams.addRule(RelativeLayout.BELOW);
    keyboardParams.addRule(RelativeLayout.ABOVE);
    keyobard1.setLayoutParams(keyboardParams);



    SetVisibleKeyboard();

    //COLOR KEYBOARD
    SetKeyboardView(view);

    int ID, on;

    outerloop:
    for (int i = 1; i <= 5; i++){
        for (int z = 0; z <= 4; z++) {
            String TextViewId = "var" + i + "x" + z;
            ID = getResources().getIdentifier(TextViewId, "id", getPackageName());
            TextView xt = (TextView) findViewById(ID);
            on = xt.getId();

            if (ClickOn == on){

                TextViewX = i;
                TextViewY = z;
                break outerloop;
            }
        }
    }


}
 
Example 17
Source Project: FixMath   File: TimeAttackActivity.java    License: Apache License 2.0 2 votes vote down vote up
public void FigureClick(View view) {
    isClicked = true;
    clickedFigureID = view.getId();



    //FIGURE ANIMATION
    YoYo.with(Techniques.RubberBand)
            .duration(500)
            .playOn(findViewById(clickedFigureID));

    //KEYBOARD
    RelativeLayout keyboardView = (RelativeLayout) findViewById(R.id.t_keyboard);
    View keyboardViewID = findViewById(R.id.t_keyboard);
    setClickableRecursive(keyboardViewID, true);

    RelativeLayout.LayoutParams keyboardParams = (RelativeLayout.LayoutParams) keyboardView.getLayoutParams();

    //RESET KEYBOARD
    keyboardParams.addRule(RelativeLayout.BELOW);
    keyboardParams.addRule(RelativeLayout.ABOVE);
    keyboardView.setLayoutParams(keyboardParams);


    setVisibleKeyboard();

    //COLOR KEYBOARD
    setKeyboardView(view);


    int ID, on;
    for (int i = 0; i <= 4; i++) {
        String TextViewId = "t_var" + i;
        ID = getResources().getIdentifier(TextViewId, "id", getPackageName());
        TextView xt = (TextView) findViewById(ID);
        on = xt.getId();
        if (clickedFigureID == on) {

            TextViewIndex = i;

        }
    }


}