Sunday, December 23, 2012

Hide Soft Keyboard Android

InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);



Some other methods:

http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard

Tuesday, November 27, 2012

View Switcher layout_height="wrap_content" dosen't work

http://stackoverflow.com/questions/5466537/how-to-get-viewswitcher-to-wrap-only-the-currently-displayed-view-height

 

Solution:

 

android:measureAllChildren="false"

Monday, October 22, 2012

Check weather application sent to background or not

[java]

public static boolean isApplicationSentToBackground(final Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasks = am.getRunningTasks(1);
if (!tasks.isEmpty()) {
ComponentName topActivity = tasks.get(0).topActivity;
if (!topActivity.getPackageName().equals(context.getPackageName())) {
return true;
}
}

return false;
}

[/java]

Sunday, October 21, 2012

How to prevent a scrollview from scrolling to a webview after data is loaded?

You should create new class extend ScrollView, then Override requestChildFocus:

 
public class MyScrollView extends ScrollView {

@Override
public void requestChildFocus(View child, View focused) {
    if (focused instanceof WebView )
       return;
    super.requestChildFocus(child, focused);
}
}

Then in your xml layout, using:
<MyScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/background" >

The ScrollView will not auto scroll to the WebView anymore.

 

Solution taken from :

http://stackoverflow.com/questions/9842494/how-to-prevent-a-scrollview-from-scrolling-to-a-webview-after-data-is-loaded

 

webview showing white bar on right side

Use the following to hide but not remove the functionality of the scrollbar. The layout margin adjustment is a nasty work-around.

//webview being your WebView object reference.

webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

 

Solution from:

http://stackoverflow.com/questions/2279978/webview-showing-white-bar-on-right-side