This example demonstrates how do I detect touch and its position on Google map in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Google Maps Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport androidx.fragment.app.FragmentActivity; import android.os.Bundle; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnCameraMoveStartedListener, GoogleMap.OnCameraMoveListener, GoogleMap.OnCameraMoveCanceledListener, GoogleMap.OnCameraIdleListener { private GoogleMap mMap; @Override ... Read More
This example demonstrates how do I set the selected item of Spinner by value instead of by position on Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Spinner; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MainActivity extends AppCompatActivity { Spinner spinner; String[] FootBallPlayers = new String[]{"Lionel Messi", ... Read More
This example demonstrates how do I determine the Android device screen size category (small, normal, large, xlarge) programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.res.Configuration; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Read More
In this problem, we are given an array of numbers and we have to find the largest value that can be made by changing them in a certain way. the condition for the arrangement is, the order of even numbers and odd numbers shall remain the same i.e. the order of all even numbers cannot be changed.let's take an example to understand the concept better, Input : {17, 80, 99, 27, 14 , 22} Output: 801799271422 Explanation: the order of Even and Odd numbers is : Even : 80 14 22 Odd : 17 99 27Here 99 is the biggest ... Read More
In programming, working with files is very important and every programming language has its own set of functions or library that help in manipulation of files.In C Programming Language also there is a function remove which can be used by the programmer to delete a file.remove() function in c programmingThe remove function is used to delete the file whose name is specified. This function is in the stdio header file.Syntaxremove (“file_name”);ParametersThe function accepts one parameter which is the name of the file that is to be deleted.File name can also be the path to the file but only if the ... Read More
Disconnected graph is a Graph in which one or more nodes are not the endpoints of the graph i.e. they are not connected.A disconnected graph…Now, the Simple BFS is applicable only when the graph is connected i.e. all vertices of the graph are accessible from one node of the graph. in the above disconnected graph technique is not possible as a few laws are not accessible so the following changed program would be better for performing breadth first search in a disconnected graph.Example#include using namespace std; void insertnode(vector adj[], int u, int v) { adj[u].push_back(v); } void breathFirstSearch(int u, ... Read More
In this problem, we are given a 2D binary array i.e. it has values that are either 0 or 1, where 1 is marked as a home of a person of the group. And people of the group want to meet. So, they need to minimise the total distance travelled by them for meeting at a common point. A valid meeting point can be anywhere but not at anyone home.For find minimum distance a formula is created, this is named as manhattan distance, where distance −(p1, p2) = |p2.x| + |p2.y - p1.y|.Let’s take an example, to make the concept ... Read More
Best first search is a traversal technique that decides which node is to be visited next by checking which node is the most promising one and then check it. For this it uses an evaluation function to decide the traversal.This best first search technique of tree traversal comes under the category of heuristic search or informed search technique.The cost of nodes is stored in a priority queue. This makes implementation of best-first search is same as that of breadth First search. We will use the priorityqueue just like we use a queue for BFS.Algorithm for implementing Best First SearchStep 1 ... Read More
Advancements in technology have lead to a newer and more efficient way of learning. The usage of these modern learning techniques are gaining popularity. Modern learning methods used by teachers in e-learning are educational websites, educational applications, learning games, ebooks and virtual teaching courses.Using these modern learning methods, students can learn interactively and at their own pace. These learning apps and videos are used to transform teaching experience. It is more eco friendly technical and is more interactive as compared to traditional once which used chalk-board and pen-paper.Applications that are downloadable create an interactive environment for students to learn with ... Read More
A bell number is used to denote the number of ways a set of n elements can be partitioned into subsets that are not empty (i.e. have at least one element).In this program, we are given a set of n elements and we have to find the number of ways to partition the set into non-empty subsets.ExampleInput : 3 Output : 5Explanation − let the set of three elements {1, 2, 3}.The subsets are {{1} , {2} , {3}} ; {{1} , {2, 3}} ; {{1 , 2} , {3}} ; {{2} , {1 , 3}} ; {1 , 2 , 3}.Bell ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP