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

The following examples show how to use android.widget.TextView#getId() . 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
Source File: TempControlsFragment.java    From octoandroid with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: InstantAdapterCore.java    From adapter-kit with 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 3
Source File: RegisterServiceActivity.java    From BonjourBrowser with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: OnboardingAdjustmentHighLatitudesFragment.java    From PrayTime-Android with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: OnboardingCalculationMethodFragment.java    From PrayTime-Android with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: SnippetDetailFragment.java    From android-java-snippets-sample with MIT License 5 votes vote down vote up
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 7
Source File: SnippetDetailFragment.java    From Android-REST-API-Explorer with MIT License 5 votes vote down vote up
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 8
Source File: PlayerActivity.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: PolylinePointsControlFragment.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: MainActivity.java    From ShakeDetector with 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 11
Source File: NavigationMenuView.java    From screenplay with 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 12
Source File: Botification.java    From Botifier with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 13
Source File: PushFragment.java    From EosCommander with 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 14
Source File: SublimeRecurrencePicker.java    From SublimePicker with Apache License 2.0 4 votes vote down vote up
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
Source File: SnippetDetailFragment.java    From android-java-snippets-rest-sample with MIT License 4 votes vote down vote up
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 File: TimeAttackActivity.java    From FixMath with 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;

        }
    }


}
 
Example 17
Source File: PlayActivity.java    From FixMath with 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;
            }
        }
    }


}