Saturday, March 8, 2014

Android Libs Org

0 comments
Android Libs | Android Libs is a place to gather all open source Android UI Views, Android Libraries, Android Tools and Plugins

Android Libs Org



Android Libs Org | Android Libs Org is a place to gather all open source Android UI Views, Android Libraries, Android Tools and Plugins


Android Libs Org will help you to find the  UI Views, Libraries, Tools and Plugins.

If you found a good Android Library do not forget to contact  Android Libs Org and let them know to update it.




Android Libs Org | Android Libs Org is a place to gather all open source Android UI Views, Android Libraries, Android Tools and Plugins

Read more...

Friday, January 10, 2014

Android ScrollView with GestureDetector

0 comments

The implementation of Android GestureDetector with ScrollView 



ScrollLayoutActivity


import android.os.Bundle;
import android.app.Activity;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;

public class ScrollLayoutActivity extends Activity {

 private static String TAG = ScrollLayoutActivity.class.getSimpleName();

 private LinearLayout mTopLayout;
 private LinearLayout mMiddleLayout;
 private LinearLayout mBottomLayout;

 private ScrollView mScrollView;

 private boolean possitionTop;
 private boolean possitionMiddle = true;

 int mLayoutHeight;
 float mDeviceHeight;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_testlayouts);

  DisplayMetrics displayMetrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

  // final float height=displayMetrics.heightPixels/displayMetrics.xdpi;

  // device height in pixels
  mDeviceHeight = displayMetrics.heightPixels;
  mLayoutHeight = (int) mDeviceHeight / 3;

  mScrollView = (ScrollView) findViewById(R.id.scrv);

  mTopLayout = (LinearLayout) findViewById(R.id.top);
  mMiddleLayout = (LinearLayout) findViewById(R.id.middle);
  mBottomLayout = (LinearLayout) findViewById(R.id.bottom);

  mTopLayout.setLayoutParams(new LinearLayout.LayoutParams(mTopLayout
    .getLayoutParams().width, mLayoutHeight));
  mBottomLayout.setLayoutParams(new LinearLayout.LayoutParams(
    mBottomLayout.getLayoutParams().width, mLayoutHeight));
  mMiddleLayout.setLayoutParams(new LinearLayout.LayoutParams(
    mMiddleLayout.getLayoutParams().width, (int) mDeviceHeight));

  mScrollView.setHorizontalFadingEdgeEnabled(false);
  mScrollView.setVerticalFadingEdgeEnabled(false);
  mScrollView.post(new Runnable() {
   public void run() {
    mScrollView.scrollTo(0, mLayoutHeight);
   }
  });

  // findViewById(R.id.button).setOnClickListener(new
  // View.OnClickListener() {
  //
  // @Override
  // public void onClick(View v) {
  // Toast.makeText(ScrollLayoutActivity.this, "height : " +
  // mDeviceHeight, Toast.LENGTH_SHORT).show();
  // }
  // });

  Toast.makeText(this, "Device Height : " + mDeviceHeight,
    Toast.LENGTH_SHORT).show();

 }

 public boolean dispatchTouchEvent(MotionEvent ev) {
  return mGestureDetector.onTouchEvent(ev);
 }

 SimpleOnGestureListener simpleOnGestureListener = new SimpleOnGestureListener() {
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    float velocityY) {
   String swipe = "";
   float sensitvity = 100;

   if ((e1.getX() - e2.getX()) > sensitvity) {
    swipe += "Swipe Left\n";
   } else if ((e2.getX() - e1.getX()) > sensitvity) {
    swipe += "Swipe Right\n";
   } else {
    swipe += "\n";
   }

   if ((e1.getY() - e2.getY()) > sensitvity) {
    swipe += "Swipe Up\n";
    if (!possitionMiddle && possitionTop) {
     mScrollView.scrollBy(0, mLayoutHeight);
     possitionTop = false;
     possitionMiddle = true;
    } else if (possitionMiddle && !possitionTop) {
     mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
     possitionTop = false;
     possitionMiddle = false;
    }
   } else if ((e2.getY() - e1.getY()) > sensitvity) {
    swipe += "Swipe Down\n";
    if (possitionMiddle && !possitionTop) {
     mScrollView.fullScroll(ScrollView.FOCUS_UP);
     possitionTop = true;
     possitionMiddle = false;
    }
    if (!possitionMiddle && !possitionTop) {
     mScrollView
       .scrollTo(mScrollView.getBottom(), mLayoutHeight);
     possitionTop = false;
     possitionMiddle = true;
    }
   } else {
    swipe += "\n";
   }
   Log.d(TAG, swipe);
   return super.onFling(e1, e2, velocityX, velocityY);
  }

 };

 GestureDetector mGestureDetector = new GestureDetector(
   simpleOnGestureListener);
}




activity_scroll_layout.xml 



<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrv"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:scrollbars="none" >

    <LinearLayout
        android:id="@+id/container2"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:background="#1E1E1E"
        android:baselineAligned="false"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="@android:color/black"
            android:baselineAligned="false"
            android:orientation="vertical" >
        </LinearLayout>

        <LinearLayout
            android:id="@+id/middle"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="@android:color/white"
            android:baselineAligned="false"
            android:orientation="vertical" >

            <Button
                android:id="@+id/button"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/bottom"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@android:color/darker_gray"
            android:baselineAligned="false"
            android:orientation="vertical" >
        </LinearLayout>
    </LinearLayout>

</ScrollView>

Read more...

Tuesday, December 10, 2013

Sith Browser

2 comments

Sinhala Android web Browser | Tamil Android web Browser 

Sinhala Android web browser

Sith Browser is light weight fast Android web Browser (Sinhala Android web browser / Tamil Android web Browser). Happy Browsing
★ Sinhala web Browser
★ Tamil web Browser
Features:
- Unlimited Tabs
- Full Screen Mode
- Incognito Browsing (Incognito Mode keeps you safe while browsing,History is not saved, Cookies are disabled, and Location access is disabled to ensure as best we can that you are not being tracked )
- Bookmarks
- History
- Block Images
- Flash Support
- Fast Sinhala and Tamil Rendering
- Search Engine
- FREE No Ads
Download Sith Browser and enjoy a faster experience with Sinhala Tamil web browsing.

Tamil Android web Browser



Read more...

Friday, September 6, 2013

Android Swipe List View

1 comments


SwipeListView 

An Android List View implementation with support for drawable cells and many other swipe related features. on Android for @ 47 Degrees





Fork source code from githon Android for @ 47 Degreesub
Read more...

Thursday, June 27, 2013

Android AnimationDrawable - Loading Example

0 comments

Android Drawable Animation 


In this tutorial you will learn how to animate Image set by using Android AnimationDrawable 




loading.xml

res/anim/loading.xml


<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/voipemLoading"
    android:oneshot="false" >

    <item
        android:drawable="@drawable/loading_01"
        android:duration="300"/> 
    <item
        android:drawable="@drawable/loading_02"
        android:duration="300"/>
    <item
        android:drawable="@drawable/loading_03"
        android:duration="300"/>
    <item
        android:drawable="@drawable/loading_04"
        android:duration="300"/>

</animation-list>


DravableAnimation


package com.javasrilankansupport.drawableanimation;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;

public class DravableAnimation extends Activity implements OnClickListener {

 private AnimationDrawable mAnimation;
 private ImageView mAnimLogo;
 private Button mbtnStart;
 private boolean mStart;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.dravable_animation);

  mAnimLogo = (ImageView) findViewById(R.id.loading_image);
  mAnimation = (AnimationDrawable) mAnimLogo.getDrawable();
  mbtnStart = (Button) findViewById(R.id.btn_start);

  mbtnStart.setOnClickListener(this);
 }

 @Override
 public void onClick(View v) {
  if (!mStart) {
    // start animation 
   mAnimLogo.post(new Runnable() {
    @Override
    public void run() {
     mAnimLogo.setVisibility(View.VISIBLE);
     mAnimation.start();
     mStart = true;
     mbtnStart.setText("Stop");
    }
   });
  } else {     
   // stop animation            
   mAnimation.stop();
   mbtnStart.setText("Start");
   mStart = false;
  }
 }
}


dravable_animation.xml


<RelativeLayout 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"
    tools:context=".DravableAnimation"
    android:background="@drawable/bg_login" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="44dp"
        android:text="@string/hello_world"
        android:textColor="@color/black"
        android:textSize="24sp" />

    <ImageView
        android:id="@+id/loading_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="37dp"
        android:src="@anim/loading"
        android:visibility="invisible" />

    <Button
        android:id="@+id/btn_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/loading_image"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp"
        android:text="@string/btn_start" />

</RelativeLayout>

Download AnimationDrawable complete source code 




Read more...

How to move an image from left to right and right to left in android

1 comments

Android Animation with TranslateAnimation

In this tutorial you will learn how to animate an image from left to right and right to left in android using TranslateAnimation


Android Animation TranslateAnimation



     ImageView img_animation = (ImageView) findViewById(R.id.img_animation);

        TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,
                0.0f, 0.0f);          //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
        animation.setDuration(5000);  // animation duration 
        animation.setRepeatCount(5);  // animation repeat count
        animation.setRepeatMode(2);   // repeat animation (left to right, right to left )
//      animation.setFillAfter(true);      

        img_animation.startAnimation(animation);  // start animation 


Animation 


package com.javasrilankansupport.animation;

import android.os.Bundle;
import android.app.Activity;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class Animation extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.);

  ImageView img_animation = (ImageView) findViewById(R.id.img_animation);

  TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,
    0.0f, 0.0f);
  animation.setDuration(5000);
  animation.setRepeatCount(5);
  animation.setRepeatMode(2);
  animation.setFillAfter(true);
  img_animation.startAnimation(animation);

 }
}


activity_animation.xml


 
<RelativeLayout 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"
    tools:context=".Animation" >
    
    <ImageView
        android:id="@+id/img_animation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="42dp"
        android:src="@drawable/emo_im_crying" />

</RelativeLayout>



Read more...

Tuesday, June 25, 2013

Android OnKeyListener Example

0 comments
In this post you will learn how to implement Android OnKeyListener with EditText

android onkeylistener javasrilankansupport.com

EditTextKeyListener

EditTextKeyListener class implement the Android OnKeyListener interface





package com.javasrilankansupport.androidkeylistner;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.Toast;
import android.app.Activity;

public class EditTextKeyListener extends Activity implements OnKeyListener {

 private EditText userName;
 private EditText password;

 private String mUserName;
 private String mPassword;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_keylistner);

  userName = (EditText) findViewById(R.id.txt_name);
  password = (EditText) findViewById(R.id.password);

  // set onkeyListner
  userName.setOnKeyListener(this);
  password.setOnKeyListener(this);

 }

 @Override
 public boolean onKey(View v, int keyCode, KeyEvent event) {

  switch (v.getId()) {

  case R.id.txt_name:
   // keyup and "ENTER"
   if ((event.getAction() == KeyEvent.ACTION_DOWN)
     && (keyCode == KeyEvent.KEYCODE_ENTER)) {
    mUserName = userName.getText().toString();
    if (mUserName.equals("")) {
     Toast.makeText(this, "Enter user name...",
       Toast.LENGTH_SHORT).show();

    } else
     password.requestFocus();
   }
   break;

  case R.id.password:
   // keydown and "ENTER"
   if ((event.getAction() == KeyEvent.ACTION_DOWN)
     && (keyCode == KeyEvent.KEYCODE_ENTER)) {
    mPassword = password.getText().toString();
    if (mPassword.equals(""))
     Toast.makeText(this, "Enter password...",
       Toast.LENGTH_SHORT).show();

    else
     // show Toast Long time
     Toast.makeText(
       this,
       "User name : " + mUserName + "  Password : "
         + mPassword, Toast.LENGTH_LONG).show();
   }
   break;

  }
  return false;
 }

}

activity_keylistener.xml


<RelativeLayout 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"
    tools:context=".EditTextKeyListener" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world"
        android:textSize="20sp" />

    <EditText
        android:id="@+id/txt_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="48dp"
        android:ems="10"
        android:inputType="textPersonName" 
        android:hint="@string/username"
       >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/txt_name"
        android:layout_below="@+id/txt_name"
        android:layout_marginTop="24dp"
        android:ems="10"
        android:inputType="textPassword"
        android:hint="@string/psass" />

</RelativeLayout>


Download Android KeyListener project

Read more...

Tuesday, March 19, 2013

How to Install Android SDK properly in ubuntu 12.04 amd64

0 comments

Android SDK in ubuntu 12.04 amd64


Android SDK is not working properly in ubuntu 12.04 amd64 , because ubuntu 12.04 64-bit dose not   have  ia32-libs package. So it gives adb error on Eclipse like 

error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

This can solve by installing  the required libraries which is for i386 version 

Open the terminal and execute following command 

sudo apt-get install libncurses5:i386 libstdc++6:i386 libz1:i386 libc6:i386 libsdl1.2debian:i386


NB: 

If you unable to launch Android emulator, execute the following command which will install ia32-libs package

sudo apt-get install ia32-libs




Read more...

Monday, November 26, 2012

How To Add Line Numbers in Eclipse

0 comments
By adding line numbers in eclipse, it makes a little easier to debug , find and fix errors in your project.

  • To add line numbers Eclipse -> Window -> Preferences 
  • Select General -> Editors -> Text Editors and tick on Show line numbers

how to add line numbers in eclipse
Read more...

Tuesday, November 13, 2012

AsyncTask Android example | AsyncTask in Android

12 comments
In this tutorial you will learn how to use AsyncTask in your application. This AsyncTask class perform background operations and update the results on the UI

AsyncTask has three generic type
  • Params, the type of the parameters sent to the task upon execution.
  • Progress, the type of the progress units published during the background computation.
  • Result, the type of the result of the background computation

Private class ShowDialogAsyncTask extends 
        AsyncTask<Params, Progress, Result>{....}


AsyncTask goes through 4 steps

  • onPreExecute(),invoked on the UI thread immediately after the task is executed.
  •  doInBackground(Paaram ...),invoked on the background thread immediately after onPreExecute() finishes executing.
  • onProgressUpdate(Progress...) invoked on the UI thread after a call to publishProgress(Progress...).
  •  onPostExecute(Result), invoked on the UI thread after the background computation finishes. 


Android AcyncTask Example Android ProgressBar

AsyncTaskActivity


package com.javasrilankansupport.asynctask;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;


public class AsyncTaskActivity extends Activity {

 Button btn_start;
 ProgressBar progressBar;
 TextView txt_percentage;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_async_task);
        
        btn_start = (Button) findViewById(R.id.btn_start);
        progressBar =  (ProgressBar) findViewById(R.id.progress);
        txt_percentage= (TextView) findViewById(R.id.txt_percentage);
        
        btn_start.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    
    btn_start.setEnabled(false);
    new ShowDialogAsyncTask().execute();
   }
  });
    }

    
    private class ShowDialogAsyncTask extends AsyncTask<Void, Integer, Void>{

     int progress_status;
     
     @Override
  protected void onPreExecute() {
   // update the UI immediately after the task is executed
   super.onPreExecute();
   
    Toast.makeText(AsyncTaskActivity.this,
            "Invoke onPreExecute()", Toast.LENGTH_SHORT).show();

    progress_status = 0;
    txt_percentage.setText("downloading 0%");
   
  }
     
  @Override
  protected Void doInBackground(Void... params) {
   
   while(progress_status<100){
    
    progress_status += 2;
    
    publishProgress(progress_status);
    SystemClock.sleep(300);
    
   }
   return null;
  }
 
  @Override
  protected void onProgressUpdate(Integer... values) {
   super.onProgressUpdate(values);
   
   progressBar.setProgress(values[0]);
   txt_percentage.setText("downloading " +values[0]+"%");
   
  }
  
  @Override
  protected void onPostExecute(Void result) {
   super.onPostExecute(result);
   
    Toast.makeText(AsyncTaskActivity.this,
            "Invoke onPostExecute()", Toast.LENGTH_SHORT).show();
    
    txt_percentage.setText("download complete");
    btn_start.setEnabled(true);
  }
    }
}


activity_async_task.xml

<RelativeLayout 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" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:padding="@dimen/padding_medium"
        android:text="@string/async_task"
        tools:context=".AsyncTaskActivity" />

    <ProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="34dp" />

    <Button
        android:id="@+id/btn_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/progress"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:minWidth="120dp"
        android:text="@string/start_btn" />

    <TextView
        android:id="@+id/txt_percentage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/progress"
        android:text="downloading  0%"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>



Download AsyncTask Android example


You may also like 


Read more...