List of usage examples for android.app Activity findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:ObservableScrollView.ViewPagerTab2RecyclerViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_recyclerview, container, false); Activity parentActivity = getActivity(); final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll); recyclerView.setLayoutManager(new LinearLayoutManager(parentActivity)); recyclerView.setHasFixedSize(false); recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container)); if (parentActivity instanceof ObservableScrollViewCallbacks) { recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity); }/*from w ww .j a va 2 s . c o m*/ return view; }
From source file:dat255.grupp06.bibbla.fragments.ProfileFragment.java
/** * Update the debt TextView./*from ww w .j av a2 s . co m*/ * @param msg Backend response, */ private void fetchDebtDone(Message msg) { Activity activity = getSherlockActivity(); int debt = (Integer) msg.obj; TextView debtView = (TextView) activity.findViewById(R.id.debt_view); if (debtView != null) debtView.setText(String.format(getString(R.string.debt_view_text), debt)); debtPending = false; //updateSpinnerState(); }
From source file:com.dalaran.annotation.validator.Validator.java
private boolean checkFiledToEquals(Activity a, EqualsWith length, EditText o) { o.setError(null);/*w w w. j av a2 s. c o m*/ String s = o.getText().toString(); boolean matches = ((EditText) a.findViewById(length.value())).getText().toString().equals(s); if (!matches) { o.setError(a.getString(length.message())); } return !matches; }
From source file:com.android.argb.edhlc.Utils.java
public static void createRecordListElement(Activity parent, Record currentRecord, String highlightedPlayerName) { TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard); LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard); TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard); TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard); TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard); View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard); LinearLayout linearSecondLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearSecondLineRecordCard); TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard); TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard); TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard); View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard); LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard); TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard); TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard); TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard); View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard); LinearLayout linearFourthLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearFourthLineRecordCard); TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard); TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard); TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard); Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL); int colorAccent = ContextCompat.getColor(parent, R.color.accent_color); int colorSecondary = ContextCompat.getColor(parent, R.color.secondary_text); textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate())); switch (currentRecord.getTotalPlayers()) { case 2:/*w w w. j av a2s .c o m*/ linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.GONE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.GONE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 3: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 4: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.VISIBLE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.VISIBLE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName()); textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFourthIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; } }
From source file:dat255.grupp06.bibbla.fragments.ProfileFragment.java
/** * The method is called from a callback object when the backend is done * fetching the username./*from w w w .j av a 2 s. c om*/ * @param msg - Message object containing the username and error messages. */ private void getUserNameDone(Message msg) { Activity activity = getSherlockActivity(); String name = (String) msg.obj; TextView nameHeading = (TextView) activity.findViewById(R.id.name_heading); if (nameHeading != null) nameHeading.setText(name); namePending = false; //updateSpinnerState(); }
From source file:io.palaima.debugdrawer.DebugWidgetsFrame.java
/** * Set the gravity for the drawer. START, LEFT | RIGHT, END *///from www . j a va 2 s . co m public DebugWidgetsFrame(Activity activity, List<BaseDebugModule> debugModules) { this.activity = activity; this.rootView = (ViewGroup) activity.findViewById(android.R.id.content); this.debugModules = debugModules; if (rootView == null || rootView.getChildCount() == 0) { throw new RuntimeException( "You have to set your layout for this activity with setContentView() first."); } init(); }
From source file:com.ultramegatech.ey.ElementListFragment.java
/** * Setup the listener for the sort button. *//* ww w.j a v a 2s.c o m*/ private void setupSort() { final Activity activity = getActivity(); if (activity == null) { return; } final Button sortButton = (Button) activity.findViewById(R.id.sort); sortButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { openSortDialog(); } }); }
From source file:es.mdelapenya.uned.master.is.ubicomp.sensors.activities.RangeDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.range_detail, container, false); lbDetail = (TextView) rootView.findViewById(R.id.range_detail); txtName = (EditText) rootView.findViewById(R.id.range_name); txtMin = (EditText) rootView.findViewById(R.id.range_min); txtMax = (EditText) rootView.findViewById(R.id.range_max); String title = getContext().getString(R.string.new_range); if (range.getId() > 0) { title = range.getName();/*w w w.j a va2 s.c o m*/ int resourceByName = ResourceLocator.getStringResourceByName(getContext(), range.getName()); if (resourceByName != 0) { title = getContext().getString(resourceByName); } } range.setName(title); lbDetail.setText(range.toString()); txtName.setText(title); txtMin.setText(String.valueOf(range.getMin())); txtMax.setText(String.valueOf(range.getMax())); Activity activity = this.getActivity(); final CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity .findViewById(R.id.toolbar_layout); if (appBarLayout != null) { appBarLayout.setTitle(title); } txtName.addTextChangedListener(createNameTextWatcher(appBarLayout)); txtMin.addTextChangedListener(createMinTextWatcher(lbDetail)); txtMax.addTextChangedListener(createMaxTextWatcher(lbDetail)); return rootView; }
From source file:org.jorge.lbudget.ui.util.undobar.UndoBar.java
/** * Checks if there is already an {@link UndoBarView} instance added to the * given {@link Activity}.<br>//from w ww . j av a 2s .com * If {@code true}, returns that instance.<br> * If {@code false}, inflates a new {@link UndoBarView} and returns it. */ private UndoBarView getView(Activity activity) { ViewGroup rootView = (ViewGroup) activity.findViewById(android.R.id.content); UndoBarView undoBarView = (UndoBarView) rootView.findViewById(R.id.undoBar); if (undoBarView == null) { undoBarView = (UndoBarView) LayoutInflater.from(activity).inflate(R.layout.other_ui_undo_bar, rootView, false); rootView.addView(undoBarView); } return undoBarView; }
From source file:com.andrew.apollo.ui.fragments.profile.AlbumSongFragment.java
/** * {@inheritDoc}//from ww w.j av a2 s.c o m */ @Override public void onAttach(final Activity activity) { super.onAttach(activity); mProfileTabCarousel = (ProfileTabCarousel) activity.findViewById(R.id.acivity_profile_base_tab_carousel); }