I'm trying to implement Floating Search View from this library: Floating Search View so everything working fine but when implementing this code
floatingSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() {
#Override
public void onSuggestionClicked(final SearchSuggestion searchSuggestion) {
Log.d("ssssssss", "clicked");
mLastQuery = searchSuggestion.getBody();
}
#Override
public void onSearchAction(String query) {
}
});
it's not working please help me.
after 6 hours i found the answer my mistake was in xml design so i put floating search view first child in coordinator layout so i change it to the last child and it worked perfectly
Related
I'm using FancyShowCaseView library. When focusing on a button it work fine, but when focusing on TabLayout or MenuItem of Android SlidingTabs it don't work.
I'm tring to focus on TabLayout or MenuItem's of my app.
listen i have the same problem and add this:
view.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
// Layout has happened here.
// Don't forget to remove your listener when you are done with it.
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
to my code and work fine.
I have a custom control inheriting from LinearLayout and I want to add a child control to it as soon as I know the size of this custom control.
What's the correct method to do this?
The below code is working fine:
yourView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
#Override
public boolean onPreDraw() {
//yourView.getWidth()
yourView.getViewTreeObserver().removeOnPreDrawListener(this);
return true;
}
});
Hope this will help.
you have to override onFinishInflate() method inside the custom layout. That is the callback called when all views has been inflated. Use this and addd your views.
This might help:
/**
* Great workaround to get view infos after it has been drawn
*/
mCustomView.post(new Runnable() {
#Override
public void run() {
//The code you want to run
}
});
I have a problem using Clans FloatingActionButton. I need to add a transparent layer that blocks the parent layer. The effect that I need is similar to Google Inbox.
So in my example I have this sequence:
1) Click item 3
2) Click on fab
3) When I click over transparent layer, the item from ListView is clicked.
I try to block the click event transparent layer using:
final FloatingActionMenu menu1 = (FloatingActionMenu) findViewById(R.id.menu1);
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
}
});
So with this code, when I click transparent layer the fab menu is closed (this is ok), but the same click listener blocking the click event over listView.
I have tried different ways to solve this problem but the only way I found was to resize the background programmatically . This is not a good solution because the effect is not good.
In a few hours I'll upload a demo and source code to github , but even as hope someone can help me with some idea. Thank You
EDITED
Here is the LINK to my repo.
Here is the LINK to download this apk
Here is the LINK to video demo
I have download your project from Github and tried the code myself and have solved the issue.
It is working perfectly for me as demonstrated in the Inbox by Google app. You just need to change a very small portion of your code.
menu1.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
#Override
public void onMenuToggle(boolean opened) {
if (opened) {
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
menu1.setClickable(false);
}
});
} else {
Toast.makeText(getApplicationContext(), "Close", Toast.LENGTH_SHORT).show();
}
}
});
Hope I could help you.
I am stuck in a very weird situation, my SearchView is working perfectly.
I just need to use OnActionExpandListener and for that purpose,
I have to set app:showAsAction="ifRoom|collapseActionView"
in my SearchView item in menu layout.
What it does is, it distorts my SearchView icon.
If I use app:showAsAction="always", OnActionExpandListener stops working but icon is shown perfectly.
Any kind of help is this regard will be highly appreciated, thanks.
Edit:
See the comments on the answer.
I agree, they have failed doing this nicely.
Anyway, I use this instead in order to detect when SearchView is being expanded/closed.
searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
#Override
public void onViewAttachedToWindow(View v) {
// Opened
}
#Override
public void onViewDetachedFromWindow(View v) {
// Closed
}
});
I have several custom ImageViews which are added to a RelativeLayout dynamically.
public class EmptySoldierView extends ImageView {
.
.
#Override
public void onClick(View v) {
EmptySoldierView.this.getAnimation().cancel();
clickListener.onEmptySoldierClicked(player, regionID);
}
}
And I am trying to remove all of these custom views like this:
#Override
public void onEmptySoldierClicked(Player player, int areaID) {
player.addSoldier(areaID);
drawSoldier(player, areaID);
for (EmptySoldierView soldierView : emptySoldiers)
((ViewGroup) soldierView.getParent()).removeView(soldierView);
}
I know the correct way (documented) to remove views is using above approach. But it is not working in my case. I searched, read a lot of posts and struggled for three days before asking.
How to remove dynamically added custom views?
I figured it out. The problem is Animation. View is removed from layout however animation is still on image. animation.cancel() is not enough. I added setAnimation(null) before removing View.