Posts

Custom onClick Listener for RecyclerView

Image
Easiest Way to Implement Custom Click Listener for Recycler View Hello friends, in this blog post I am going to show you that how one can make a custom onClick Listener for the RecyclerView As an Android Developer we all know that ListView has its own onClick Listener. We do not want to do code for that. But unfortunately it is not the same situation in case of the Recycler View. We have to additionally do code for getting the onClick functionality for the Recycler View. So lets get started. First add the following dependencies to your project: dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner...

MultiSelection of Item in Recycler View

Image
Easiest Way to Implement Multi Selection of Item in Recycler View Hello friends, in this blog post I am going to show you that how one can make a multi selection functionality for items in the Recycler View So lets get started. First add the following dependencies to your project: dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' //Recycler View Dependency implementation 'androidx.recyclerview:recyclerview-selection:1.0.0' } Now in this project we have two XML layout file: For Main...

Water Jug Problem using Breath First Search

Image
Water Jug Problem AI Problem Statement: In a Water Jug Problem you are given two jugs, one 4-gallon and one 3-gallon, a pump which has unlimited water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug? This problem can be solve using multiple techniques of Artificial Intelligence (AI). Here we are going to solve the Water Jug Problem using the Breath First Search (BFS) Algorithm. Here is the code for the current problem statement.

Water Jug Problem using Depth First Search

Image
Problem Statement: In a Water Jug Problem you are given two jugs, one 4-gallon and one 3-gallon, a pump which has unlimited water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug? This problem can be solve using multiple techniques of Artificial Intelligence (AI). Here we are going to solve the Water Jug Problem using the Depth First Search (DFS) Algorithm. To solve the problem with Breath First Search (BFS), check it here. Here is the code for the current problem statement. Firstly, let include all the header files. Now we have to define a structure for the nodes which we are going to use it for the further process. Below code snippet of code is for the same. #include<stdio.h> #include<conio.h> struct node { int x, y; struct node *next; }*root, *left, *right; Now we have to check weather the node whi...

Upload Image From Android To Php Server

Image
Hello friends, in this tutorial we will learn how to upload an image from android to php server. Lets go for it. Prerequisites: Android Studio Xampp or Wamp Server (I am using Xampp here) Text Editor (I recommend to use Sublime) Structure of the Database: Firstly, we use our Android Studio to make our front part ready to capture the photo and get it ready to upload on the server. To get start with the actual code add the permissions and dependencies to make the project work properly. Add below permissions in the Manifests file. <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission> And add the volley dependency in the build.gradle file of the App Module. implementation 'com.android.volley:volley:1.1.1' So, initially we make our layout for the Main Activity. Here is the layout co...

Array in JAVA

Image
Using Of Array in JAVA with Example Array is a container or a collection which has the similar kind of data types. Array is stored in contiguous memory.  In JAVA, arrays behave as an object. We can find the length and do other manipulations using the in-build functions. For using array in the JAVA program we have to declare an array using the int data type and not long or not short. Decleration of array can be done by,

Merge Sort

Image
Merge Sort in C In  computer science ,  merge sort  (also commonly spelled  mergesort ) is an efficient, general-purpose,  comparison-based   sorting algorithm . Most implementations produce a  stable sort , which means that the implementation preserves the input order of  equal  elements in the sorted output. Mergesort is a  divide and conquer algorithm  that was invented by  John von Neumann  in 1945. Algorithm Conceptually, a merge sort works as follows: Divide the unsorted list into  n  sublists, each containing 1 element (a list of 1 element is considered sorted). Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.