[Android Apps and Games] hoanngothanh:
Can somebody help me, I have stuck on this for 2 day.

I want creat a dictionary app like this app

play.google.com/store/apps/details?id=com.vng.dict.app

It have "Quick search window". When user click on small icon it show popup search window. I implement this by create a "QuickSearchWindow" class.

@Override
public int getAppIcon() {
return 0;
}

@Override
public void createAndAttachView(int id, FrameLayout frame) {
if (id == 0) {
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.quick_search_window, frame, true);
etQuickSearch = (EditText) view.findViewById(R.id.editext_quicksearch);
tvMeaningQuickSearch = (TextView) view.findViewById(R.id.tv_meaning_quicksearch);
etQuickSearch.setText(keyWord);
} else if (id == 1) {
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.search_icon, frame, true);
}
// imgQuickSearch = (ImageView) view.findViewById(R.id.quick_search_icon);
// linearSearchLayout = (LinearLayout) view.findViewById(R.id.quicksear_layout);
}

@Override
public StandOutLayoutParams getParams(int id, Window window) {

if (id == 1) {
return new StandOutLayoutParams(id, 50, 50,
200, 200);
}
return new StandOutLayoutParams(id, 300, 500,
StandOutLayoutParams.RIGHT, StandOutLayoutParams.BOTTOM);
}

@Override
public int getThemeStyle() {
return R.style.Base_Theme_AppCompat;
}

@Override
public int getFlags(int id) {
if (id == 0) {
return super.getFlags(id)
| StandOutFlags.FLAG_BODY_MOVE_ENABLE
| StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE
;
}
return super.getFlags(id)
| StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE
| StandOutFlags.FLAG_BODY_MOVE_ENABLE;
}

@Override
public boolean onTouchBody(int id, Window window, View view, MotionEvent event) {
if (id == 0 && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
hide(0);
} else if (id == 1 && event.getAction() == MotionEvent.ACTION_UP) {
long time = event.getEventTime()-event.getDownTime();
if (time<300) {
StandOutWindow.show(getApplicationContext(), QuickSearchWindow.class, 0);
}
}
return super.onTouchBody(id, window, view, event);
}

public void setShowLayout() {
if (isShowLayout) {
imgQuickSearch.setVisibility(View.GONE);
linearSearchLayout.setVisibility(View.VISIBLE);
} else {
imgQuickSearch.setVisibility(View.VISIBLE);
linearSearchLayout.setVisibility(View.GONE);
}
}

@Override
public boolean onHide(int id, Window window) {
if (id == 0) {
StandOutWindow.show(getApplicationContext(), QuickSearchWindow.class, 1);
}
return super.onHide(id, window);

}

@Override
public boolean onShow(int id, Window window) {
if (id == 0) {

StandOutWindow.hide(getApplicationContext(), QuickSearchWindow.class, 1);
}
return super.onShow(id, window);
}

I start QuicksearchWindow like this :

StandOutWindow.show(getActivity(), QuickSearchWindow.class,1);
StandOutWindow.show(getActivity(), QuickSearchWindow.class,0);

If id==1 inflate search_icon.xml, if id==0 inflate quick_search_window.xml.

It still have a bug: When i click on icon it show search window, but when i double click on search icon both window is hide.

P/s: How to reduce delay time when show or hide window. Thanks in advance!!:o