Posts

Showing posts from August, 2021

Onclicklistner on recycler view to go in next activity

  package com.codewithmadde.foodyhut.Adapters ; import android.content.Context ; import android.content.Intent ; import android.view.LayoutInflater ; import android.view.View ; import android.view.ViewGroup ; import android.widget.ImageView ; import android.widget.TextView ; import androidx.annotation. NonNull ; import androidx.recyclerview.widget.RecyclerView ; import com.codewithmadde.foodyhut.DetailActivity ; import com.codewithmadde.foodyhut.Models.MainModel ; import com.codewithmadde.foodyhut.R ; import java.util.ArrayList ; public class MainAdapter extends RecyclerView.Adapter<MainAdapter.viewholder> { ArrayList<MainModel> list ; Context context ; public MainAdapter (ArrayList<MainModel> list , Context context) { this . list = list ; this . context = context ; } @NonNull @Override public viewholder onCreateViewHolder ( @NonNull ViewGroup parent , int viewType) { View view= LayoutInflater. from ( context ).infla

horizontal scroll view in android studio

  <HorizontalScrollView android :layout_width ="match_parent" android :layout_height ="180dp" app :layout_constraintEnd_toEndOf ="parent" app :layout_constraintStart_toStartOf ="parent" app :layout_constraintTop_toTopOf ="parent" tools :ignore ="SpeakableTextPresentCheck" > <LinearLayout android :layout_width ="wrap_content" android :layout_height ="wrap_content" android :background ="#FFFFFF" android :orientation ="horizontal" > <ImageView android :id ="@+id/imageView1" android :layout_width ="130dp" android :layout_height ="180dp" android :layout_weight ="1" app :srcCompat ="@drawable/rec1" /> <ImageView android :id ="@+id/imageView3" android :layou

bitwise hack for compatitive programming

  // how to set bit in the number #include <bits/stdc++.h> using   namespace   std ; // this is for set a bit in number at pos void   settheory ( int   & num ,  int   pos ){ num |= ( 1 << pos ); } int   main (){      int  num = 4 , pos = 1 ;      settheory (num, pos);     cout << ( int )(num) << endl ;      return   0 ; } // this is unset a bit in a number in given pos void   unset ( int   & num ,  int   pos ){      num &= ( ~ ( 1 << pos )); } int   main (){      int  num = 7 ;      int  pos = 1 ;      unset (num, pos);     cout << num << endl ;      return   0 ; } // toggling a bit in nth position  void   toggel ( int   & num ,  int   pos ){      num ^= ( 1 << pos ); } int   main () {      int  num = 4 ;      int  pos = 1 ;      toggel (num, pos);     cout << num << endl ;      return   0 ; } // checking a bit at n th position is set or unset bool   at_pos ( int   num ,  int   pos ){    bool  bit = num & (