Android: Detect softkeyboard open

Here is my solution: 1/ A simple interface public interface KeyboardVisibilityListener { void onKeyboardVisibilityChanged(boolean keyboardVisible); } 2/ A utility method (put it where you want, for instance in a class named KeyboardUtil) public static void setKeyboardVisibilityListener(Activity activity, KeyboardVisibilityListener keyboardVisibilityListener) { View contentView = activity.findViewById(android.R.id.content); contentView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { private int mPreviousHeight; @Override public void onGlobalLayout() { … Read more

Android – how to find multiple views with common attribute

I’ve finally wrote this method (Updated thanks to @SuitUp (corrected username)): private static ArrayList<View> getViewsByTag(ViewGroup root, String tag){ ArrayList<View> views = new ArrayList<View>(); final int childCount = root.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = root.getChildAt(i); if (child instanceof ViewGroup) { views.addAll(getViewsByTag((ViewGroup) child, tag)); } final Object tagObj … Read more

Validate email addresses in Mysql

You can use a pure SELECT to validate Email Addresses: SELECT * FROM `users` WHERE `email` NOT REGEXP ‘^[^@]+@[^@]+\.[^@]{2,}$’; And now for your question of tracking multiple tables, you can use comma seperated table names right? SELECT * FROM `users`, `customers`, `clients` WHERE `email` NOT REGEXP “^[a-zA-Z0-9][a-zA-Z0-9.!#$%&’*+-/=?^_`{|}~]*?[a-zA-Z0-9._-]?@[a-zA-Z0-9][a-zA-Z0-9._-]*?[a-zA-Z0-9]?\\.[a-zA-Z]{2,63}$”;

How to draw view on top of soft keyboard like WhatsApp?

Well, I have created a sample keyboard for chatting here… Here, I use popup window for showing popup window and height of popup is calculated dynamically by height of keyboard // Initially defining default height of keyboard which is equal to 230 dip final float popUpheight = getResources().getDimension( R.dimen.keyboard_height); changeKeyboardHeight((int) popUpheight); // Creating a pop … Read more

MySQL Views and index use

If you query a view, MySQL will consider using indexes on the underlying tables. However it is not possible to add a new index to a calculated column in the view. I think this is what people meant by MySQL not having indexed views, as opposed to (for example) SQL Server’s indexed views.

ASP.NET MVC – View with multiple models

String-indexed ViewData is bad. What you probably want to do is make a little wrapper class for your multi-variable view data and pass that to a strongly typed view. IE: public class FooBarViewData { public Foo Foo {get; set;} public Bar Bar {get; set;} } public ActionResult Edit() { FooBarViewData fbvd = new FooBarViewData(); fbvd.Foo … Read more