Java Code Examples for androidx.cardview.widget.CardView#setOnClickListener()
The following examples show how to use
androidx.cardview.widget.CardView#setOnClickListener() .
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: GenerateActivity.java From SecScanQR with GNU General Public License v3.0 | 6 votes |
/** * Standard Android on create method that gets called when the activity * initialized. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); generalHandler = new GeneralHandler(this); generalHandler.loadTheme(); setContentView(R.layout.activity_generate); barcodeCard = (CardView) findViewById(R.id.barcode_card); textCard = (CardView) findViewById(R.id.text_card); geoCard = (CardView) findViewById(R.id.geo_card); contactCard = (CardView) findViewById(R.id.contact_card); wifiCard = (CardView) findViewById(R.id.wifi_card); barcodeCard.setOnClickListener(this); textCard.setOnClickListener(this); geoCard.setOnClickListener(this); contactCard.setOnClickListener(this); wifiCard.setOnClickListener(this); }
Example 2
Source File: MainActivity.java From SecScanQR with GNU General Public License v3.0 | 6 votes |
/** * Standard Android on create method that gets called when the activity * initialized. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); generalHandler = new GeneralHandler(this); generalHandler.loadTheme(); setContentView(R.layout.activity_main); scanCard = (CardView) findViewById(R.id.scan_card); generateCard = (CardView) findViewById(R.id.generate_card); historyCard = (CardView) findViewById(R.id.history_card); settingsCard = (CardView) findViewById(R.id.settings_card); scanCard.setOnClickListener(this); generateCard.setOnClickListener(this); historyCard.setOnClickListener((View.OnClickListener) this); settingsCard.setOnClickListener(this); //Autostart Scanner if activated SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Boolean auto_scan = prefs.getBoolean("pref_start_auto_scan", false); if(auto_scan == true){ startActivity(new Intent(MainActivity.this, ScannerActivity.class)); } }
Example 3
Source File: MoDialogView.java From a with GNU General Public License v3.0 | 5 votes |
/** * 显示图像和文本 */ public void showImageText(Bitmap bitmap, String text) { removeAllViews(); LayoutInflater.from(getContext()).inflate(R.layout.mo_dialog_image_text, this, true); CardView cardView = findViewById(R.id.cv_content); cardView.setOnClickListener(null); ImageView imageView = findViewById(R.id.image_view); TextView tvCanCopy = findViewById(R.id.tv_can_copy); int imageWidth = Math.min(cardView.getWidth(), cardView.getHeight()); imageView.setMaxWidth(imageWidth - 20); imageView.setMaxHeight(imageWidth - 20); imageView.setImageBitmap(bitmap); tvCanCopy.setText(text); }
Example 4
Source File: DNSRelaysAdapter.java From InviZible with GNU General Public License v3.0 | 5 votes |
DNSRelaysViewHolder(@NonNull View itemView) { super(itemView); CardView cardDNSRelay = itemView.findViewById(R.id.cardDNSRelay); cardDNSRelay.setCardBackgroundColor(context.getResources().getColor(R.color.colorFirst)); cardDNSRelay.setFocusable(true); cardDNSRelay.setOnClickListener(this); cardDNSRelay.setOnFocusChangeListener(this); tvDNSRelayName = itemView.findViewById(R.id.tvDNSRelayName); tvDNSRelayDescription = itemView.findViewById(R.id.tvDNSRelayDescription); chbDNSRelay = itemView.findViewById(R.id.chbDNSRelay); chbDNSRelay.setOnCheckedChangeListener(this); }
Example 5
Source File: MoDialogView.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 显示图像和文本 */ public void showImageText(Bitmap bitmap, String text) { removeAllViews(); LayoutInflater.from(getContext()).inflate(R.layout.mo_dialog_image_text, this, true); CardView cardView = findViewById(R.id.cv_content); cardView.setOnClickListener(null); ImageView imageView = findViewById(R.id.image_view); TextView tvCanCopy = findViewById(R.id.tv_can_copy); int imageWidth = Math.min(cardView.getWidth(), cardView.getHeight()); imageView.setMaxWidth(imageWidth - 20); imageView.setMaxHeight(imageWidth - 20); imageView.setImageBitmap(bitmap); tvCanCopy.setText(text); }
Example 6
Source File: StarkSpinner.java From SSForms with GNU General Public License v3.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mRevealContainerCardView = (CardView) findViewById(R.id.CrdVw_RevealContainer); mRevealContainerCardView.setOnClickListener(mOnRevelViewClickListener); mRevealItem = (LinearLayout) findViewById(R.id.FrmLt_SelectedItem); mStartSearchImageView = (IconTextView) findViewById(R.id.ImgVw_StartSearch); mContainerCardView = (CardView) findViewById(R.id.CrdVw_Container); mSearchEditText = (AppCompatEditText) findViewById(R.id.EdtTxt_SearchEditText); mDoneSearchImageView = (IconTextView) findViewById(R.id.ImgVw_DoneSearch); init(); }
Example 7
Source File: SimpleColorDialogDesignAdapter.java From toktok-android with GNU General Public License v3.0 | 5 votes |
@NonNull @Override public SimpleColorDialogDesignViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) { CardView itemView = (CardView) LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.simple_color_dialog_item, viewGroup, false); itemView.setOnClickListener(v -> { logger.debug("adsd"); v.setZ(1000.0f); }); return new SimpleColorDialogDesignViewHolder(itemView); }
Example 8
Source File: DeviceControlCardItemPetView.java From arcusandroid with Apache License 2.0 | 4 votes |
@Override public void build(@NonNull PetControlCard card) { super.build(card); CardView cardView = (CardView) findViewById(R.id.cardView); View divider = findViewById(R.id.divider); if (cardView != null) { if (card.isOffline()) { cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.overlay_white_with_10)); divider.setBackgroundColor(getContext().getResources().getColor(R.color.black_with_10)); } else { cardView.setCardBackgroundColor(Color.TRANSPARENT); divider.setBackgroundColor(getContext().getResources().getColor(R.color.overlay_white_with_10)); } } Version1TextView titleText = (Version1TextView) findViewById(R.id.card_device_control_title_text); Version1TextView modeButton = (Version1TextView) findViewById(R.id.mode_button); Version1TextView descText = (Version1TextView) findViewById(R.id.card_device_control_description_text); RelativeLayout modeButtonRegion = (RelativeLayout) findViewById(R.id.mode_button_clickable_region); ImageView chevronButton = (ImageView) findViewById(R.id.card_device_control_chevron); GlowableImageView topButton = (GlowableImageView) findViewById(R.id.card_device_control_device_image); if(card.getDeviceId() !=null){ final DeviceModel model = SessionModelManager.instance().getDeviceWithId(card.getDeviceId(), false); if(model!=null) { topButton.setVisibility(VISIBLE); ImageManager.with(getContext()) .putSmallDeviceImage(model) .withTransformForStockImages(new BlackWhiteInvertTransformation(Invert.BLACK_TO_WHITE)) .withPlaceholder(R.drawable.device_list_placeholder) .withError(R.drawable.device_list_placeholder) .noUserGeneratedImagery() .into(topButton) .execute(); if(card.getGlowMode() !=null){ topButton.setGlowMode(card.getGlowMode()); topButton.setGlowing(card.shouldGlow()); } }else{ topButton.setVisibility(VISIBLE); topButton.setImageResource(R.drawable.device_list_placeholder); } }else{ if(card.getTopImageResource() == 0){ topButton.setVisibility(INVISIBLE); }else{ topButton.setVisibility(VISIBLE); topButton.setImageResource(card.getTopImageResource()); } } topButton.setEnabled(card.isTopButtonEnabled()); topButton.setAlpha(card.isTopButtonEnabled() ? BUTTON_ENABLED_ALPHA : BUTTON_DISABLED_ALPHA); titleText.setText(card.getTitle()); descText.setText(card.getDescription()); modeButton.setText(card.getPetDoorStatus()); mListener = card.getCallbackListener(); cardView.setOnClickListener(this); modeButton.setOnClickListener(this); chevronButton.setOnClickListener(this); topButton.setOnClickListener(this); modeButtonRegion.setOnClickListener(this); if (card.isDividerShown()) { showDivider(); } }
Example 9
Source File: PopupCardItemView.java From arcusandroid with Apache License 2.0 | 4 votes |
public void build(@NonNull PopupCard card) { super.build(card); TextView title = (TextView)this.findViewById(R.id.title); title.setText(card.getTitle()); if(card.getTitleColor() != -1) { title.setTextColor(card.getTitleColor()); } else if (card.isDarkColorScheme()) { title.setTextColor(Color.BLACK); } TextView description = (TextView)this.findViewById(R.id.description); if (card.getDescription() != null) { description.setText(card.getDescription()); if (card.getTitleColor() != -1) { description.setTextColor(card.getTitleColor()); } else if (card.isDarkColorScheme()) { description.setTextColor(Color.BLACK); } } else { description.setVisibility(GONE); } CardView cardView = (CardView) findViewById(R.id.cardView); if (cardView != null) { cardView.setCardBackgroundColor(Color.TRANSPARENT); cardView.setOnClickListener(this); } listener = card.getClickListener(); TextView rightText = (TextView) this.findViewById(R.id.right_text); if (card.getRightText() != null) { rightText.setVisibility(VISIBLE); rightText.setText(card.getRightText()); if (card.isDarkColorScheme()) { rightText.setTextColor(Color.BLACK); } } else { rightText.setVisibility(GONE); } if (card.isDividerShown()) { showDivider(card.isDarkColorScheme()); } showChevron(card.isDarkColorScheme()); }
Example 10
Source File: SubGroupAdapter.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void inflateView(@NonNull final ViewHolder holder, final int keyIndex, final int modelId, final int modelCount, final int position) { final View view = LayoutInflater.from(mContext).inflate(R.layout.grouped_item, holder.mGroupGrid, false); final CardView groupContainerCard = view.findViewById(R.id.group_container_card); final ImageView icon = view.findViewById(R.id.icon); final TextView groupSummary = view.findViewById(R.id.group_summary); final Button on = view.findViewById(R.id.action_on); final Button off = view.findViewById(R.id.action_off); if (MeshParserUtils.isVendorModel(modelId)) { icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_domain_48dp)); view.findViewById(R.id.container_buttons).setVisibility(View.INVISIBLE); view.findViewById(R.id.container_vendor).setVisibility(View.VISIBLE); final TextView modelIdView = view.findViewById(R.id.subtitle); modelIdView.setText(CompositionDataParser.formatModelIdentifier(modelId, true)); final TextView companyIdView = view.findViewById(R.id.company_id); final int companyIdentifier = MeshParserUtils.getCompanyIdentifier(modelId); companyIdView.setText(String.valueOf(CompanyIdentifiers.getCompanyName((short) companyIdentifier))); groupSummary.setText(mContext.getResources().getQuantityString(R.plurals.device_count, modelCount, modelCount)); } else { switch (modelId) { case SigModelParser.GENERIC_ON_OFF_SERVER: groupSummary.setText(mContext.getResources().getQuantityString(R.plurals.light_count, modelCount, modelCount)); break; case SigModelParser.GENERIC_ON_OFF_CLIENT: icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_light_switch_48dp)); view.findViewById(R.id.container_buttons).setVisibility(View.INVISIBLE); groupSummary.setText(mContext.getResources().getQuantityString(R.plurals.switch_count, modelCount, modelCount)); break; case SigModelParser.GENERIC_LEVEL_SERVER: icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_lightbulb_level_48dp)); groupSummary.setText(mContext.getResources().getQuantityString(R.plurals.dimmer_count, modelCount, modelCount)); break; default: icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_help_outline_48dp)); view.findViewById(R.id.container_buttons).setVisibility(View.INVISIBLE); groupSummary.setText(mContext.getResources().getQuantityString(R.plurals.device_count, modelCount, modelCount)); break; } } groupContainerCard.setOnClickListener(v -> onSubGroupItemClicked(keyIndex, modelId)); on.setOnClickListener(v -> toggleState(keyIndex, modelId, true)); off.setOnClickListener(v -> toggleState(keyIndex, modelId, false)); holder.mGroupGrid.addView(view, position); }
Example 11
Source File: EntityActionViewUtils.java From commcare-android with Apache License 2.0 | 4 votes |
private static void setupActionClickListener(FrameLayout actionCardView, final Action action, final CommCareActivity commCareActivity) { CardView cardView = actionCardView.findViewById(R.id.card_body); cardView.setOnClickListener(v -> EntitySelectActivity.triggerDetailAction(action, commCareActivity)); }