Java Code Examples for androidx.cardview.widget.CardView#findViewById()

The following examples show how to use androidx.cardview.widget.CardView#findViewById() . 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: ServerStatusPreference.java    From FCM-for-Mojo with GNU General Public License v3.0 6 votes vote down vote up
private void updateStatus(CharSequence text, @AttrRes int attr, Drawable icon) {
    if (mViewHolder != null) {
        CardView statusCard = (CardView) ((ViewGroup) mViewHolder.itemView).getChildAt(0);
        TextView status = statusCard.findViewById(android.R.id.text1);

        if (icon != null) {
            icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
            status.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            status.setCompoundDrawablesRelative(null, null, null, null);
        }
        status.setText(text);

        int[] attrs = {attr};
        TypedArray a = getContext().obtainStyledAttributes(attrs);
        int color = a.getColor(0, 0);
        a.recycle();

        statusCard.setCardBackgroundColor(color);
    }
}
 
Example 2
Source File: CardViewHolder.java    From science-journal with Apache License 2.0 5 votes vote down vote up
public CardViewHolder(CardView itemView) {
  super(itemView);
  chartView = (ChartView) itemView.findViewById(R.id.chart_view);
  sensorSelectionArea = itemView.findViewById(R.id.sensor_selection_area);
  sensorTabLayout = (TabLayout) itemView.findViewById(R.id.sensor_selector_tab_layout);
  sensorSettingsGear = (ImageButton) itemView.findViewById(R.id.settings_gear);
  sensorTabHolder = (ViewGroup) itemView.findViewById(R.id.sensor_selection_tab_holder);
  graphStatsList = (StatsList) itemView.findViewById(R.id.stats_drawer);
  header = (SensorCardHeader) itemView.findViewById(R.id.sensor_card_header);
  headerText = (TextView) itemView.findViewById(R.id.sensor_card_header_title);
  toggleButton = (ToggleArrow) itemView.findViewById(R.id.btn_sensor_card_toggle);
  toggleButtonSpacer = itemView.findViewById(R.id.sensor_card_toggle_spacer);
  menuButton = (ImageButton) itemView.findViewById(R.id.btn_sensor_card_overflow_menu);
  graphViewGroup = (ViewGroup) itemView.findViewById(R.id.graph_view_content_group);
  meterSensorIconContainer =
      (RelativeLayout) itemView.findViewById(R.id.card_meter_sensor_icon_container);
  meterLiveData = (SingleLineResizableTextView) itemView.findViewById(R.id.live_sensor_value);
  statusViewGroup = (ViewGroup) itemView.findViewById(R.id.status_view_content_group);
  statusProgressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar);
  statusMessage = (TextView) itemView.findViewById(R.id.status_message);
  statusRetryButton = (Button) itemView.findViewById(R.id.status_retry_button);
  triggerSection = (RelativeLayout) itemView.findViewById(R.id.sensor_card_trigger_section);
  triggerIcon = (ViewSwitcher) itemView.findViewById(R.id.trigger_icon_view_switcher);
  triggerLevelDrawableButton = (ImageButton) itemView.findViewById(R.id.sensor_trigger_icon);
  triggerTextSwitcher = (TextSwitcher) itemView.findViewById(R.id.trigger_text_switcher);
  triggerFiredBackground =
      (TriggerBackgroundView) itemView.findViewById(R.id.sensor_trigger_fired_background);
  triggerFiredText = (TextView) itemView.findViewById(R.id.trigger_fired_text);
  infoButton = (ImageButton) itemView.findViewById(R.id.btn_info);

  WindowManager windowManager =
      (WindowManager) itemView.getContext().getSystemService(Context.WINDOW_SERVICE);
  screenOrientation = windowManager.getDefaultDisplay().getRotation();
}
 
Example 3
Source File: SimpleColorDialogDesignAdapter.java    From toktok-android with GNU General Public License v3.0 4 votes vote down vote up
SimpleColorDialogDesignViewHolder(@NonNull CardView itemView) {
    super(itemView);
    mColor = itemView.findViewById(R.id.simple_color_dialog_item);
}