Friday, 8 February 2013

SlideDrawer in Android

ScreenShots:



strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">SlidingDrawer</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>
    <string name="menuname">Menu</string>
    <string name="item1">option1</string>
    <string name="item2">option2</string>
    <string name="item3">option3</string>
    <string name="item4">option4</string>
    <string name="item5">option5</string>

</resources>

activity_main.xml:

<?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" >
    <SlidingDrawer
        android:id="@+id/slidingDrawer1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:content="@+id/content"
        android:handle="@+id/handle"
        android:topOffset="50dip" >
    

        <Button
            android:id="@+id/handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/menuname" >
        </Button>
    

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#FF444444"
            android:gravity="center"
            android:orientation="vertical" >
      

            <Button
                android:id="@+id/item1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/item1" >
            </Button>
      

            <Button
                android:id="@+id/item2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/item2">
            </Button>
      

            <Button
                android:id="@+id/item3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/item3" >
            </Button>
      

            <Button
                android:id="@+id/item4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
              android:text="@string/item4" >
            </Button>
      

            <Button
                android:id="@+id/item5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/item5" >
            </Button>
    
        </LinearLayout>
  
    </SlidingDrawer>

</LinearLayout>

MainActivity.java:

package com.ram.slidingdrawer;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

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

Button i1 = (Button)findViewById(R.id.item1);

i1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "clicked", Toast.LENGTH_SHORT).show();
}
});
}


}



1 comment:

  1. Hi ram... will you please provide code which can communicate to oracle db and access it.

    or

    a sample app login app whose username and password will validate from oracle db.

    Post all required info

    ReplyDelete