touch event when finger moves to next view - android

I am dragging my finger and it moves to the next view. Both views implement setOnTouchListener().
How to find out that the finger is now on second view.
ACTION_MOVE is getting returned for first view even though my finger is on second view.
Do I need to implement any other listener?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.textview.MainActivity" >
<TextView
android:id = "#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id = "#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world1" />
<TextView
android:id = "#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world2" />
</LinearLayout>
MainActivity.java:
package com.example.textview;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView txt1 = (TextView) findViewById(R.id.text1);
txt1.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent e) {
TextView txt1 = (TextView) findViewById(v.getId());
Log.d("txt1.getText()",txt1.getText().toString());
return false;
}
});
txt1 = (TextView) findViewById(R.id.text2);
txt1.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent e) {
TextView txt1 = (TextView) findViewById(v.getId());
Log.d("txt1.getText()",txt1.getText().toString());
return false;
}
});
txt1 = (TextView) findViewById(R.id.text3);
txt1.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent e) {
TextView txt1 = (TextView) findViewById(v.getId());
Log.d("txt1.getText()",txt1.getText().toString());
return false;
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

You can check for the current MotionEvent x and y is in the 2nd view hit rect
Rect viewHitRect = new Rect();
secondView.getHitRect(viewHitRect);
if(viewHitRect.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {//You are in 2nd view}

When finger is coming on textview2, it will get ACTION_HOVER_ENTER and
textview1 will get ACTION_HOVER_EXIT
Check on these parameters, ACTION_MOVE will be given to textview1 as you mentioned but hover parameter clearly decide which textfield is under finger at this time
UPDATE :
If finger is clicked on views then you will get ACTION_DOWN on textview2 and parallely textview1 will get ACTION_UP

Related

Getting "Unfortunately, app has stopped" while executing

I am learning Android dev in Android Studio.
I created an app which displays some text on fling and some other on click of a button.
But its showing "Unfortunately app has stopped"
Also, I have only one activity. So, its not possible that I forgot to show it in AndroidManifest.xml
here is my java code :
package com.example.mahe.pro2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Button;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.support.v4.view.GestureDetectorCompat;
public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener {
private TextView tv = (TextView) findViewById(R.id.t);
private GestureDetectorCompat gd;
private Button bt = (Button) findViewById(R.id.b);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.gd = new GestureDetectorCompat(this,this);
bt.setOnClickListener(
new Button.OnClickListener() {
public void onClick(View v) {
tv.setText("That was a Click!");
}
}
);
}
#Override
public void onLongPress(MotionEvent motionEvent) {
}
#Override
public boolean onSingleTapUp(MotionEvent motionEvent) {
return false;
}
#Override
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
return false;
}
#Override
public void onShowPress(MotionEvent motionEvent) {
}
#Override
public boolean onDown(MotionEvent motionEvent) {
return false;
}
#Override
public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
tv.setText("That was a Swipe, Baby");
return true;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
this.gd.onTouchEvent(event);
return super.onTouchEvent(event);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Here's my xml code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="YO!"
android:id="#+id/t"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click"
android:id="#+id/b"
android:layout_below="#+id/t"
android:layout_centerHorizontal="true"
android:layout_marginTop="164dp" />
Just move
TextView tv = (TextView) findViewById(R.id.t);
Button bt = (Button) findViewById(R.id.b);
under onCreate(...) after setContentView(R.layout.activity_main);
as #M D said
you must first create your view and setview to can get R.id.b
but if you want to declare them as a global variable , use
private TextView tv;
private Button bt
above the onCreate Method , then in onCreate method and under
setContentView(R.layout.activity_main);
use
tv = (TextView) findViewById(R.id.t);
bt = (Button) findViewById(R.id.b);

Android Scrollview + horizantal scrollview + zoomcontrols

i am using to learn zoomcontrols. i am now at the begining android.
when closer if i, It does not seem a part of the picture. codes below. please help me
i dont want pinc zoom.. i want simply button zoom. and i am sorry for my English :( i hope you are understand me..
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/resim"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<ZoomControls
android:id="#+id/zoomControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
and java
package com.example.kusem.ikiliscrollldenemeleri;
import android.annotation.TargetApi;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Layout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.ZoomControls;
public class MainActivity extends ActionBarActivity {
ImageView iv;
ZoomControls zoom;
ScrollView sv;
HorizontalScrollView hsv;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
zoom= (ZoomControls) findViewById(R.id.zoomControls);
iv= (ImageView) findViewById(R.id.resim);
// hsv= (HorizontalScrollView) findViewById(R.id.hsv);
iv.setImageResource(R.drawable.resim2);
zoom.setOnZoomInClickListener(new View.OnClickListener() {
#TargetApi(Build.VERSION_CODES.HONEYCOMB)
#Override
public void onClick(View v) {
float x = iv.getScaleX();
float y = iv.getScaleY();
iv.setScaleX((float)(x+1));
iv.setScaleY((float)(y+1));
}
});
zoom.setOnZoomOutClickListener(new View.OnClickListener() {
#TargetApi(Build.VERSION_CODES.HONEYCOMB)
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
float x = iv.getScaleX();
float y = iv.getScaleY();
iv.setScaleX((float) (x-1));
iv.setScaleY((float) (y-1));
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Thank you in advance for your help..

App force close when changing items in StringArray, Android?

right now I'm working on a app which changes items in StringArray on button clicks. I've implemented left and right buttons, when I click right button the item changes by right, when I press left the item changes to left. Up to here everything is fine, but when I click left button when the item is on Steve Jobs the app force closes. Any idea why this is happening?
Strings.xml:
<string name="sj">Steve Jobs</string>
<string name="mz">Mark Zuckerberg</string>
<string name="bg">Bill Gates</string>
<string name="lp">Larry Page</string>
<string-array name="gl">
<item>#string/sj</item>
<item>#string/mz</item>
<item>#string/bg</item>
<item>#string/lp</item>
</string-array>
MainActivity.java:
package com.example.theatremode;
import android.support.v7.app.ActionBarActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity implements OnClickListener {
int counter = 0;
TextView tv1;
Button button1;
Button button2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.tv1);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
Resources res = getResources();
final String[] list = res.getStringArray(R.array.gl); // get the array
((TextView) findViewById(R.id.tv1)).setText(list[counter]); // set the
// initial
// message.
button1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
TextView tx = (TextView) findViewById(R.id.tv1);
counter++;
if (counter >= list.length)
counter = 0;
tx.setText(list[counter]); // set the new message.
}
});
Resources res2 = getResources();
final String[] list2 = res2.getStringArray(R.array.gl); // get the array
((TextView) findViewById(R.id.tv1)).setText(list2[counter]);
button2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
TextView tx2 = (TextView) findViewById(R.id.tv1);
counter--;
if (counter >= list2.length)
counter = 0;
tx2.setText(list2[counter]); // set the new message.
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.theatremode.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:id="#+id/tv1"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_alignLeft="#+id/tv1"
android:text="Left" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="48dp"
android:layout_marginRight="14dp"
android:text="Right" />
Looks like you have a IndexOutOfBoundsException.
It's not obvious exactly what's going on here, but this might fix it:
button2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
TextView tx2 = (TextView) findViewById(R.id.tv1);
counter--;
//if (counter >= list2.length)
//counter = 0;
if (counter < 0)
counter = list2.length - 1;
tx2.setText(list2[counter]); // set the new message.
}
});

Display touch coordinates on screen

My objective is to have the user touch anywhere on the screen, and then to have the touch coordinates appear in a textview on the screen.
This is what I have so far.
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="#+id/touchView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="To be filled" />
</LinearLayout>
Main Activity.java:
package com.example.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.MyFirstApp.MESSAGE";
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView textView = (TextView)findViewById(R.id.textView1);
// this is the view on which you will listen for touch events
final View touchView = findViewById(R.id.touchView);
touchView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
textView.setText("Touch coordinates : " +
String.valueOf(event.getX()) + "x" + String.valueOf(event.getY()));
return true;
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
SOLVED My first problem is that on MainActivity.java, there is an error on line 18, in the code setContentView(R.layout.main);. Researching online, it looks like the way to fix this error is to change import android.R; to import your.application.packagename.R;. However, I do not have import android.R; in my .java file. Does anyone know how to fix this error?
EDIT Second, the textView only displays the touch coordinates when the first textview is clicked, it does not display the touch coordinates of a touchpoint anywhere on the screen (it only displays the touch coordinates of a touch point on the first text view). How can I change this so that the touch coordinates of anywhere on the screen are displayed?
Another Edit One idea I had for the second problem was giving the LinearLayout I had an id, such as android:id="#+id/touchLayout". I was then planning on modifying the .java file as such:
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.MyFirstApp.MESSAGE";
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView textView = (TextView)findViewById(R.id.textView1);
// this is the view on which you will listen for touch events
final View touchLayout = findViewById(R.id.touchLayout);
touchLayout.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
textView.setText("Touch coordinates : " +
String.valueOf(event.getX()) + "x" + String.valueOf(event.getY()));
return true;
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Change the following:
setContentView(R.layout.activity_main);
Yup, the answer I had in the second edit was correct. I simply replaced gave the LinearLayout an id, and replaced the touchView id with the LinearLayout id

Handling touch Events for all layouts in xml

I have a linear layout which contains 5 linear layouts as its child. I want to handle the touch event for each child linear layouts. My layout looks like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container">
<LinearLayout android:id="#+id/item1"
android:layout_width="match_parent"
style="#style/NavLinkItemContainer"
android:layout_height="wrap_content">
<TextView
style="#style/NaviLinkSelected"
android:text="First"/>
</LinearLayout>
<LinearLayout android:id="#+id/item2"
android:layout_width="match_parent"
style="#style/NavLinkItemContainer"
android:layout_height="wrap_content">
<TextView
style="#style/NaviLinks"
android:text="Second"/>
</LinearLayout>
<LinearLayout android:id="#+id/item3"
android:layout_width="match_parent"
style="#style/NavLinkItemContainer"
android:layout_height="wrap_content">
<TextView
style="#style/NaviLinks"
android:text="Third"/>
</LinearLayout>
<LinearLayout android:id="#+id/item4"
android:layout_width="match_parent"
style="#style/NavLinkItemContainer"
android:layout_height="wrap_content">
<TextView
style="#style/NaviLinks"
android:text="Fourth"/>
</LinearLayout>
<LinearLayout android:id="#+id/item5"
android:layout_width="match_parent"
style="#style/NavLinkItemContainer"
android:layout_height="wrap_content">
<TextView
style="#style/NaviLinks"
android:text="Fifth"/>
</LinearLayout>
</LinearLayout>
and My activity using the layout looks like
public class MainActivity extends Activity implements OnTouchListener{
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
public boolean onTouch(View v, MotionEvent event) {
Log.d("","ON TOUCH VIEW ######## "+v.getId());
return false;
}
}
When touching the child layouts, am not getting id(item1,item2...) in onTouch Event
Please advice.
For each layout you want to add touch listener, set onTouchListener.
for example,
LinearLayout l1 = (LinearLayout) findViewById(R.id.item2);
l1.setOntouchListener(this);
So for each ViewGroup you have to set the listener. The rest of things is already done by your. Int onTouch method you can handle touch or all ViewGroup
#Override
public boolean onTouch(View v, MotionEvent event) {
switch (v.getId()) {
case R.id.item2:
do something
break;
case R.id.item3:
do something
break;
default:
break;
}
// if you want to consume the behavior then return true else retur false
}
Here is a solution to add an OnTouchListener to every element in the constraint, which will hide the keyboard every time you touch something but an object in the exclusion list.
import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatCallback;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ConstraintLayout constraintLayout = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText editText = findViewById(R.id.editText);
//Get current ViewGroup. Might have to add an id in the layout xml for the constraint.
constraintLayout = findViewById(R.id.constraint);
//List of items that should be excluded
ArrayList<Integer> listOfExclusion = new ArrayList<>();
listOfExclusion.add(editText.getId());
addTouchListeners(listOfExclusion, constraintLayout);
}
/**
* #param excludedResIds ArrayList of list of ids that should be excluded by the addTouchListener
* #param parent ViewGroup containing the elements you want to lose focus off.
*/
void addTouchListeners(ArrayList<Integer> excludedResIds, ViewGroup parent){
parent.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
constraintLayout.requestFocus();
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
return false;
}
});
addTouchListener(excludedResIds,parent);
}
/**
* #param excludedResIds ArrayList of list of ids that should be excluded by the addTouchListener
* #param parent ViewGroup containing the elements you want to lose focus off.
*/
void addTouchListener(ArrayList<Integer> excludedResIds, ViewGroup parent)
{
for(int index = 0; index<parent.getChildCount(); ++index) {
View nextChild = parent.getChildAt(index);
try{
addTouchListener(excludedResIds, (ViewGroup) nextChild);
}catch (Exception e){
}
if(!excludedResIds.contains(nextChild.getId()))
nextChild.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
constraintLayout.requestFocus();
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
return false;
}
});
}
}
}

Categories

Resources