View

Tuesday, 2 August 2011

How to use swipe in android?

Swipe is otherwise called  as a Fling. Its a touch free movement in android.
Before that we have set some SWIPE MIN,MAX Distance,Threshold_velosity and as well as path.
 private static final int SWIPE_MIN_DISTANCE = 120;
  private static final int SWIPE_MAX_OFF_PATH = 250;
 private static final int SWIPE_THRESHOLD_VELOCITY = 200;
 private GestureDetector gestureDetector;
 View.OnTouchListener gestureListener;
 private Animation slideLeftIn;
 private Animation slideLeftOut;
 private Animation slideRightIn;
        private Animation slideRightOut;
        private ViewFlipper viewFlipper;
Next step is to write a code inside of the onCreate Method
        setContentView(R.layout.main);
        viewFlipper = (ViewFlipper)findViewById(R.id.flipper);
        slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
        slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
        slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
        slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);
       
        gestureDetector = new GestureDetector(new MyGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };
You will need to extend SimpleOnGestureListener to implement your own handling on swipe/fling action:

 class MyGestureDetector extends SimpleOnGestureListener {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
                    return false;
                // right to left swipe
                if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                 viewFlipper.setInAnimation(slideLeftIn);
                    viewFlipper.setOutAnimation(slideLeftOut);
                 viewFlipper.showNext();
                }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                 viewFlipper.setInAnimation(slideRightIn);
                    viewFlipper.setOutAnimation(slideRightOut);
                 viewFlipper.showPrevious();
                }
            } catch (Exception e) {
                // nothing
            }
            return false;
        }
    }
At last, you need to make sure in your activity, you catch the gesture event by overriding onTouch() method:
 
@Override
    public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event))
         return true;
     else
      return false;
    }
Here i use viewflipper,two LinearLayouts and two Buttons in main.xml file you have to set as <ViewFlipper xmlns:android="http://......" like this

<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/flipper"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
   
 <LinearLayout
  android:layout_width="fill_parent" android:layout_height="70dp" android:background="#E2A9F3">
  <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_marginTop="10dp" android:text="Swipe Me" android:textSize="20dp" android:textColor="#DF0101"></TextView>
    </LinearLayout>  
    <LinearLayout
  android:layout_width="fill_parent" android:layout_height="60dp" android:background="#585858">
     <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Back"></Button>
     <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Next"></Button>
    </LinearLayout>  
</ViewFlipper>
At last thing u have to create a new folder and set name as anim or what u wish ,u give it.In that folder you have to  create a xml for Left_in,Left_out,Right_in and right_out and set the values.
name:slide_left_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="800"/>
</set>
name:slide_left_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="800"/>
</set>
name:slide_right_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="800"/>
</set>
name:slide_right_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="800"/>
</set>

Result:
 

Monday, 1 August 2011

How to use Menu Option in Android?

Its a very simple way to use menu option in android, just only four line to write it. first u have to  create new folder and name as menu
example res/menu/sample.xml.
give some options what u want ,Here i gave file,open,save and edit

<?
<
xml version="1.0" encoding="utf-8"?>menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/file" android:title="@string/file" />
<item android:id="@+id/open" android:title="@string/open"/> <item android:id="@+id/save" android:title="@string/save" />
<item android:id="@+id/edit" android:title="@string/edit"/> </menu>
after that we have to set a values in strings.xml
example:values/strings.xml
<?
<
xml version="1.0" encoding="utf-8"?>resources>
<string name="hello">Hello World, MenuScreen!</string>
<string name="app_name">SampleMenu</string>
<string name="file">File</string>
<string name="open">Open</string>
<string name="save">Save</string>
</
<string name="edit">Edit</string>resources>
now you have to write a code to show the menu options.
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.sample, menu);         
        return true;
    }
Result is:

Thursday, 7 July 2011

How to use Multi Language in android?

How to use multi language of text in android?

Its just a easy way to use it.How ? The html decimal unicode is suppoted by android os.Here i show three languages,Tamil,hindi and Telungu.First of all u should download the DLL file.For example :
"Akshar.ttf",Its a one of the Library file,It help to convert the decimal unicode format.Your Android application there is assests folder ,you just create a new folder and name as fonts,then put inside of the "Akshar.ttf" file in that folder,Now come to our Code section.

 TextView english,tamil,hin,tel;
String tam,h,t;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tamil=(TextView)findViewById(R.id.textView2);
        hin=(TextView)findViewById(R.id.hindi);
        tel=(TextView)findViewById(R.id.telngu);
        tam="&#3000;&#2965;&#45;&#2949;&#2985;&#3021;&#2975;&#3021;&#2992;&#3018;&#2951;&#2975;&#3021; &#2949;&#2986;&#3021;&#2986;&#3021;&#2994;&#3007;&#2965;&#2975;&#3007;&#2962;&#2985;&#3021;&#46;&#2986;&#3021;&#2994;&#3018;&#2965;&#3021;&#3000;&#3021;&#2986;&#3018;&#2975;&#3021;&#46;&#2965;&#3018;&#2990;&#3021;";
        h="&#2360;&#2327;&#45;&#2309;&#2344;&#2381;&#2337;&#2381;&#2352;&#2379;&#2311;&#2337;&#2381; &#2309;&#2346;&#2381;&#2346;&#2381;&#2354;&#2367;&#99;&#2309;&#2335;&#2367;&#2323;&#2344;&#2381;&#46;&#2348;&#2381;&#2354;&#2379;&#2327;&#2381;&#2360;&#2381;&#2346;&#2379;&#2335;&#2381;&#46;&#99;&#2323;&#2350;&#2381;";
        t="&#3128;&#3095;&#45;&#3077;&#3112;&#3149;&#3105;&#3149;&#3120;&#3146;&#3079;&#3105;&#3149; &#3077;&#3114;&#3149;&#3114;&#3149;&#3122;&#3135;&#99;&#3077;&#3103;&#3135;&#3090;&#3112;&#3149;&#46;&#3116;&#3149;&#3122;&#3146;&#3095;&#3149;&#3128;&#3149;&#3114;&#3146;&#3103;&#3149;&#46;&#99;&#3090;&#3118;&#3149;        ";
       
        Typeface tf=Typeface.createFromAsset(getAssets(), "fonts/Akshar.ttf");
       
      
        tamil.setTypeface(tf,Typeface.BOLD);
        tamil.setText(Html.fromHtml(tam));
       
        hin.setTypeface(tf,Typeface.ITALIC);
        hin.setText(Html.fromHtml(h));
       
       
        tel.setTypeface(tf,Typeface.NORMAL);
        tel.setText(Html.fromHtml(t));
       
    }
}


The output is:
Download full source code

Saturday, 2 July 2011

How to use Autocomplete searchbox in Database?

Autocomplete means it show the complete text automatically.It have two types
1.Single line autocomplete
2.Multi line autocomplete
what letter we type in the searchbox,that letter of the complete words  to show.Here i use autocomplete searchbox ,The select item can pass into the textview
.I use DATABASE NAME as="itemsearchsqlite.db",TABLE NAME as="itemsearch" and DB COLUMN NAME as="item_name".
I use two java classes namely Home.java and SQLiteItemsearch.java
//SQLiteItemSearch.java//
------------------------
package com.autocomplete.sample;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class SQLiteItemSearch extends SQLiteOpenHelper
{
    private static final String DB_NAME = "itemsearchsqlite.db";
    private static final int DB_VERSION_NUMBER = 1;
    private static final String DB_TABLE_NAME = "itemsearch";
    private static final String DB_COLUMN_1_NAME = "item_name";

    private static final String DB_CREATE_SCRIPT = "create table " + DB_TABLE_NAME +
                            " (_id integer primary key autoincrement, item_name text not null);)";

    private SQLiteDatabase sqliteDBInstance = null;

    public SQLiteItemSearch(Context context)
    {
        super(context, DB_NAME, null, DB_VERSION_NUMBER);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        // TODO: Implement onUpgrade
    }

    @Override
    public void onCreate(SQLiteDatabase sqliteDBInstance)
    {
        Log.i("onCreate", "Creating the database...");
        sqliteDBInstance.execSQL(DB_CREATE_SCRIPT);
    }

    public void openDB() throws SQLException
    {
        Log.i("openDB", "Checking sqliteDBInstance...");
        if(this.sqliteDBInstance == null)
        {
            Log.i("openDB", "Creating sqliteDBInstance...");
            this.sqliteDBInstance = this.getWritableDatabase();
        }
    }

    public void closeDB()
    {
        if(this.sqliteDBInstance != null)
        {
            if(this.sqliteDBInstance.isOpen())
                this.sqliteDBInstance.close();
        }
    }

    public long insertitmSearch(String ItemBrandName)
    {
        ContentValues contentValues = new ContentValues();
        contentValues.put(DB_COLUMN_1_NAME, ItemBrandName);
        Log.i(this.toString() + " - insertitmSearch", "Inserting: " + ItemBrandName);
        return this.sqliteDBInstance.insert(DB_TABLE_NAME, null, contentValues);
    }

    public boolean removeitmSearch(String ItemBrandName)
    {
        int result = this.sqliteDBInstance.delete(DB_TABLE_NAME, "item_name='" + ItemBrandName + "'", null);

        if(result > 0)
            return true;
        else
            return false;
    }

    public long updateitmSearch(String oldItemBrandName, String newItemBrandName)
    {
        ContentValues contentValues = new ContentValues();
        contentValues.put(DB_COLUMN_1_NAME, newItemBrandName);
        return this.sqliteDBInstance.update(DB_TABLE_NAME, contentValues, "item_name='" + oldItemBrandName + "'", null);
    }

    public String[] getAllItemFilter()
    {
        Cursor cursor = this.sqliteDBInstance.query(DB_TABLE_NAME, new String[] {DB_COLUMN_1_NAME}, null, null, null, null, null);

        if(cursor.getCount() >0)
        {
            String[] str = new String[cursor.getCount()];
            int i = 0;

            while (cursor.moveToNext())
            {
                 str[i] = cursor.getString(cursor.getColumnIndex(DB_COLUMN_1_NAME));
                 i++;
             }
            return str;
        }
        else
        {
            return new String[] {};
        }
    }
}

Then again we have to insert a rows of dataitems inside of the Home.java class
public class Home extends Activity {
 private SQLiteItemSearch sqllitebb;
 TextView tv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_item);
       
        final AutoCompleteTextView actv=(AutoCompleteTextView)findViewById(R.id.autocompleteitem);
        sqllitebb=new SQLiteItemSearch(Home.this);
        sqllitebb.openDB();
     // Insert a few item list statically//
     
        sqllitebb.insertitmSearch("Color Monitor");
        sqllitebb.insertitmSearch("Compact Disk");
        sqllitebb.insertitmSearch("Computer");
       sqllitebb.insertitmSearch("Copy Righter");
       sqllitebb.insertitmSearch("Hard Disk");
       sqllitebb.insertitmSearch("HP Printer");
       sqllitebb.insertitmSearch("HP Laser Printer");
       sqllitebb.insertitmSearch("HP Injet Printer");
      //  sqllitebb.removeitmsearch("Computer");
       // sqllitebb.updateitmSearch("Computer","DELL");
     final  String[] deal = sqllitebb.getAllItemFilter();
      
       // Print out the values to the log
       for(int i = 0; i < deal.length; i++)
       {
           Log.i(this.toString(), deal[i]);
       }
       ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,deal);
       actv.setAdapter(adapter); 
       actv.setThreshold(1);
       actv.setOnItemClickListener(new OnItemClickListener() {
           public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            tv=(TextView)findViewById(R.id.selecteditem_tv);
            tv.setText(deal[arg2]);
            arg0.getItemAtPosition(arg2);
                Log.i("SELECTED TEXT WAS------->",  deal[arg2]);
           }
       });
    }
    public void onDestroy()
    {
        super.onDestroy();
        sqllitebb.close();
    }
}

Wednesday, 1 June 2011

How to send and receive message using in android

I take a look at how  can programmatically send and receive SMS messages in our Android applications. The good news for Android developers is that we don't need a real device to test out SMS messaging - the free Android emulator provides the capability to do so.

In the Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Enter the phone number of recipient"
        />    
    <EditText
        android:id="@+id/txtPhoneNo" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"       
        />
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"        
        android:text="Message"
        />    
    <EditText
        android:id="@+id/txtMessage" 
        android:layout_width="fill_parent"
        android:layout_height="150px"
        android:gravity="top"        
        />         
    <Button
        android:id="@+id/btnSendSMS" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Send SMS"
        />   
</LinearLayout>

Next, in the SMS activity, we wire up the Button view so that when the user clicks on it, we will check to see that the phone number of the recipient and the message is entered before we send the message using the sendSMS() function, which we will define shortly:

import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SMS extends Activity {
    /** Called when the activity is first created. */
  Button btnSendSMS;
     EditText txtPhoneNo;
     EditText txtMessage;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
        txtMessage = (EditText) findViewById(R.id.txtMessage);

        btnSendSMS.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {               
                String phoneNo = txtPhoneNo.getText().toString();
                String message = txtMessage.getText().toString();                
                if (phoneNo.length()>0 && message.length()>0)               
                    sendSMS(phoneNo, message);               
                else
                    Toast.makeText(getBaseContext(),
                        "Please enter both phone number and message.",
                        Toast.LENGTH_SHORT).show();
            }

        });       
    }
 public void sendSMS(String phoneNo, String message) {
  String SENT = "SMS_SENT";
        String DELIVERED = "SMS_DELIVERED";

        PendingIntent sentPI = PendingIntent.getBroadcast(getApplicationContext(), 0,
            new Intent(SENT), 0);

        PendingIntent deliveredPI = PendingIntent.getBroadcast(getApplicationContext(), 0,
            new Intent(DELIVERED), 0);

        //---when the SMS has been sent---
        registerReceiver(new BroadcastReceiver(){
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode())
                {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS sent",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Toast.makeText(getBaseContext(), "Generic failure",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        Toast.makeText(getBaseContext(), "No service",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Toast.makeText(getBaseContext(), "Null PDU",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Toast.makeText(getBaseContext(), "Radio off",
                                Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        }, new IntentFilter(SENT));

        //---when the SMS has been delivered---
        registerReceiver(new BroadcastReceiver(){
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode())
                {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS delivered",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case Activity.RESULT_CANCELED:
                        Toast.makeText(getBaseContext(), "SMS not delivered",
                                Toast.LENGTH_SHORT).show();
                        break;                       
                }
            }
        }, new IntentFilter(DELIVERED));       

        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNo, null, message, sentPI, deliveredPI);

 }     
}

SMS messages are received, the onCreate() method will be invoked. The SMS message is contained and attached to the Intent object (intent - the second parameter in the onReceive() method) via a Bundle object. The messages are stored in an Object array in the PDU format. To extract each message, you use the static createFromPdu() method from the SmsMessage class. The SMS message is then displayed using the Toast class:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;
 
 public class SmsReceiver extends BroadcastReceiver
 {
     @Override
     public void onReceive(Context context, Intent intent)
     {
         //---get the SMS message passed in---
         Bundle bundle = intent.getExtras();       
         SmsMessage[] msgs = null;
         String str = "";           
         if (bundle != null)
         {
             //---retrieve the SMS message received---
             Object[] pdus = (Object[]) bundle.get("pdus");
             msgs = new SmsMessage[pdus.length];           
             for (int i=0; i<msgs.length; i++){
                 msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);               
                 str += "SMS from " + msgs[i].getOriginatingAddress();                    
                 str += " :";
                 str += msgs[i].getMessageBody().toString();
                 str += "\n";       
             }
             //---display the new SMS message---
             Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
         }                        
     }
}

Tuesday, 24 May 2011

Static TableLayout

The TableLayout is built using the TableLayout and the TableRow commands. There is no TableCols like the <td> tag in HTML. To align your view in columns you have to set the width of the elements and manually control the layout.
<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content"  android:stretchColumns="0">

  <TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TextView android:id="@+id/TextView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="textfield 1-1"></TextView>

    <CheckBox android:id="@+id/CheckBox01" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox>
  </TableRow>

  <TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TextView android:id="@+id/TextView03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textfield 2-1"></TextView>
    <TextView android:id="@+id/TextView04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="textfield 2-2"></TextView>
  </TableRow>

</TableLayout>
<TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="match_parent">
    <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
        <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        <RadioButton android:text="RadioButton" android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
        <ProgressBar android:layout_height="wrap_content" android:id="@+id/progressBar1" android:layout_width="wrap_content"></ProgressBar>
    </TableRow>
</TableLayout>
<TableLayout android:id="@+id/tableLayout2" android:layout_height="wrap_content" android:layout_width="match_parent">
    <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow2">
        <SeekBar android:layout_height="wrap_content" android:id="@+id/seekBar1" android:layout_width="fill_parent"></SeekBar>
        <DigitalClock android:text="DigitalClock" android:id="@+id/digitalClock1" android:layout_width="wrap_content" android:layout_height="wrap_content"></DigitalClock>
        <ZoomButton android:src="@android:drawable/btn_plus" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/zoomButton1"></ZoomButton>
        <ToggleButton android:text="ToggleButton" android:id="@+id/toggleButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"></ToggleButton>
    </TableRow>
</TableLayout>
<TableLayout android:id="@+id/tableLayout3" android:layout_height="wrap_content" android:layout_width="match_parent" android:stretchColumns="0">
    <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
        <SeekBar android:layout_height="wrap_content" android:id="@+id/seekBar2" android:layout_width="fill_parent"></SeekBar>
    </TableRow>
</TableLayout>


How To Add a Row Dynamically

 whenever the button is clicked, it adds a new row to the TableLayout and notice the Scrollbar from the ScrollView.

XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical">

<Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click To Add New row"></Button>

<ScrollView android:id="@+id/ScrollView01" android:layout_width="wrap_content" android:layout_height="wrap_content">

  <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0">

    <TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">
        <TextView android:layout_width="fill_parent" android:text="textfield 1-1" android:layout_height="wrap_content" android:id="@+id/TextView01"></TextView>
        <ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_width="wrap_content"></ImageView>
      <DigitalClock android:text="DigitalClock" android:layout_width="wrap_content" android:id="@+id/digitalClock1" android:layout_height="wrap_content"></DigitalClock>
      <CheckBox android:id="@+id/CheckBox01" android:text="" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox>
    </TableRow>

  </TableLayout>
</ScrollView>
</LinearLayout>