Friday, April 26, 2013

Android ScrollView and bottom AdMob overlap

I have a relative layout with a scrollview and a AdMob in it. The AdMob on the bottom overlaps the the scrollview so that the bottom part of the scrollview can never be seen. After a lot of trial and error I found that the solution is simple: set the ScrollView to android:layout_above="@+id/adView".

So the layout structure is something like this:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<ScrollView
        android:id="@+id/scrollView_home"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentTop="true"
        android:background="@drawable/background"
        android:orientation="vertical" >

.....
.....
.....

</ScrollView>

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="abcdefg"
        ads:loadAdOnCreate="true" />

</RelativeLayout>

Thursday, April 25, 2013

Android app development prevent user from entering reserved characters

for example you want to reserve '-'

Step 1: create a class call it InputFilterReservedCharacters:

Step 2: in your activity do this in your onCreate event:

newNameText.setFilters(new InputFilter[]{new InputFilterReservedCharacters()});

Monday, April 08, 2013

Android app dev with SQLite ignore case

use COLLATE NOCASE

e.g. db.query("mytable", new String[]{.....}, "productname = '" + value + "' COLLATE NOCASE", null, null, null, null);