I have a TextView
and I put a OnClickListener
on this TextView
. I use this action to load custom view onto a LinearLayout
.
But when I click on this TextView
twice, custom view is repeating on the LinearLayout
. I clear all custom views on this LinearLayout
before I load new custom views on to this LinearLaout
.
This is my OnClickListener
on TextView
,
TextView rejectedTitleTextView = (TextView) findViewById(R.id.roster_menu_rejected_title);
rejectedTitleTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
rejectedTitleTextView.setBackgroundColor(getResources().getColor(R.color.acceptedPurpleColour));
newTitleTextView.setBackgroundColor(getResources().getColor(R.color.defaultBlack));
acceptedTitleTextView.setBackgroundColor(getResources().getColor(R.color.defaultBlack));
locationLinearLayout.removeAllViews();
rosterBottomLayout.setVisibility(View.GONE);
Log.d("CHECK_ACTION"," REJECTED_TEXT_VIEW ");
InternetConnectivity internetConnectivity = new InternetConnectivity();
final boolean isConnectedToInternet = internetConnectivity.isConnectedToInternet(context);
if(isConnectedToInternet==true) {
try {
Thread.sleep(1300);
} catch (Exception e) {
e.printStackTrace();
}
getDataFromServer("REJECTED");
}else{
Snackbar.make(mainView, "No Internet Connection", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
}
});
getDataFromServer("REJECTED");
is the method which I used to load custom view onto this LinearLayout
.
How can I prevent this issue ?
Have any ideas ?
Inside onclickListener put
rejectedTitleTextView.setClickable(false);
and once finish your functionality make it as true because u need to click for next time .
rejectedTitleTextView.setClickable(true);
Inside setOnclickListener
try below code:-
textView.setClickable(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With