Shake Animation Example

1.) Create a new project by File-> New -> Android Project name it ShakeAnimationExample.
2.) You will see some default code into your main.xml, strings.xml and android manifest file.
3.) Write following into main.xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dip"
        android:text="Please enter your password:"
    />
    
    <EditText android:id="@+id/pw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:singleLine="true"
        android:password="true"
    />

    <Button android:id="@+id/login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Login"
    />

</LinearLayout>

Continue Reading

“Failed to create jvm, error code – 4” Android Studio

Hi Friends,

If you are facing this problem

failed to create jvm error code -4 JVM Path: C:\Program Files\Java\jdk1.7.0_45\jre If you already have a 32-bit JDK installed, define a JAVA_HOME variable in Which is not solved.

Then here is the solution:

Go to C:\Program Files\Android\Android Studio\bin\studio.exe.vmoptions

Open it in Notepad or Notepad ++ and change the following attributes

-Xmx512m to -Xmx256m

-XX:MaxPermSize=250m to -XX:MaxPermSize=128m

OR

-Xmx750m to -Xmx512m

-XX:MaxPermSize=350m to -XX:MaxPermSize=250m

Page Curl effect with Image and Text in Android

1. Create a new project with package name – com.example.curlpagetutorial
2. Edit the main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

     <minh.app.mbook.MyLayout
        android:id="@+id/mainpage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#FFf3c5d6"
        android:orientation="vertical" />

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="9"
        android:gravity="bottom"
        android:orientation="horizontal" >
     <Button
            android:id="@+id/btn_pre"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Back" />
     <Button
            android:id="@+id/btn_next"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Next" />
    </LinearLayout>
</LinearLayout>

Continue Reading

Rotate Animation sample using XML in Android

I would like to share this example of Rotation Animation as this may be very helpful to the needy one.

In this example, I’ll try to introduce you doing simple animations with Android. It is simple enough that on clicking a button, an images starts rotating from 0 degree to 360 degree in N seconds. Lets begin with the animation XML. Once you have created a new Android project, create a folder named “anim” in res and a file named ‘rotator.xml’ inside res/anim.

res/anim/rotator.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
  <rotate
      android:fromDegrees="0"
      android:toDegrees="360"
      android:pivotX="50%"
      android:pivotY="50%"
      android:duration="2000"
      android:startOffset="0"/>
</set>

Continue Reading

Display HTML format text in WebView

I have faced this problem to show the HTML format text show in WebView
I found the solution for this and lets share it –

Create a xml with WebView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</LinearLayout>

Continue Reading

Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio

Today I was facing this issue “Cannot resolve symbol DefaultHttpClient” while parsing JSON in my application.

So Friends!! if you are also facing or will face the same issue then I’m giving you the solution for it. HttpClient was deprecated in API Level 22 and removed in API Level 23, You have to use URL Conntection. If you need SDK 23, add this to your gradle:
Continue Reading