Blog purpose for android basic example for android app developer. any query please my contact

Friday, 6 December 2024

Android studio to Show Usage of Scroll View

 Android studio to Show Usage of Scroll View


In this tutorial Learn Android studio to Show Usage of Scroll View. follow this tutorial 


1.Main Activity.java:


import android.os.Bundle;

import android.app.Activity;

import android.content.Intent;

import android.view.Menu;

import android.view.View;

import android.widget.Button;

 

public class MainActivity extends Activity {

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

 

        Button b1 = (Button) findViewById(R.id.button1);

        Button b2 = (Button) findViewById(R.id.button2);

        Button b3 = (Button) findViewById(R.id.button3);

        Button b4 = (Button) findViewById(R.id.button4);

        Button b5 = (Button) findViewById(R.id.button5);

        Button b6 = (Button) findViewById(R.id.button6);

        Button b7 = (Button) findViewById(R.id.button7);

        Button b8 = (Button) findViewById(R.id.button8);

        Button b9 = (Button) findViewById(R.id.button9);

        Button b10 = (Button) findViewById(R.id.button10);

 

        b1.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.first"));

            }

        });

 

        b2.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.second"));

            }

        });

        b3.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.third"));

            }

        });

        b4.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.fourth"));

            }

        });

        b5.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.fifth"));

            }

        });

        b6.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.sixth"));

            }

        });

        b7.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.seventh"));

            }

        });

        b8.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.eigth"));

            }

        });

        b9.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.ninth"));

            }

        });

        b10.setOnClickListener(new View.OnClickListener() {

 

            @Override

            public void onClick(View v) {

                // TODO Auto-generated method stub

                startActivity(new Intent(

                        "com.example.creating_scroll_view.tenth"));

            }

        });

    }

 

    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.main, menu);

        return true;

    }

 

}


2.First Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class first extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.first);

    }

}


3.Second Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class second extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.second);

    }

}


4.Third Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class third extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.third);

    }

}


4.Fourth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class fourth extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.fourth);

    }

}


5.Fifth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class fifth extends Activity{

 

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.fifith);

    }

}


6.Sixth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class fourth extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.fourth);

    }

}


7.Seventh Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class seventh extends Activity {

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.seventh);

    }

}


8.Eigth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class eigth extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.eighth);

    }

 

}


9.Ninth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class ninth extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.ninth);

    }

}


10.Tenth Activity.java:


import android.app.Activity;

import android.os.Bundle;

 

public class tenth extends Activity{

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.tenth);

    }

}


11.activity_main.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"

    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:background="@drawable/background1"

    tools:context=".MainActivity" >

 

    <TextView

        android:id="@+id/textView1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentTop="true"

        android:layout_marginLeft="14dp"

        android:layout_marginTop="26dp"

        android:text="A scroll View"

        android:textAppearance="?android:attr/textAppearanceLarge" />

 

    <ScrollView

        android:layout_width="match_parent"

        android:layout_height="wrap_content" >

 

        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:orientation="vertical" >

 

            <Button

                android:id="@+id/button1"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignParentLeft="true"

                android:layout_below="@+id/textView1"

                android:layout_marginTop="108dp"

                android:text="Button1" />

 

            <Button

                android:id="@+id/button2"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignRight="@+id/button1"

                android:layout_below="@+id/button1"

                android:text="Button2" />

 

            <Button

                android:id="@+id/button3"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button2"

                android:layout_below="@+id/button2"

                android:text="Button3" />

 

            <Button

                android:id="@+id/button4"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button3"

                android:layout_below="@+id/button3"

                android:text="Button4" />

 

            <Button

                android:id="@+id/button5"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button5" />

            <Button

                android:id="@+id/button6"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button6" />

            <Button

                android:id="@+id/button7"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button7" />

            <Button

                android:id="@+id/button8"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button8" />

            <Button

                android:id="@+id/button9"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button9" />

 

            <Button

                android:id="@+id/button10"

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_alignLeft="@+id/button4"

                android:layout_below="@+id/button4"

                android:text="Button10" />

 

        </LinearLayout>

    </ScrollView>

 

</RelativeLayout>


12.actvity_First.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image1">

 

 

</LinearLayout>


13.activity_Second.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image6">

 

 

</LinearLayout>


14.activity_Third.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image9">

 

 

</LinearLayout>


15.activity_Fourth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:background="@drawable/image4" >

 

 

</LinearLayout>


16.activity_Fifth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image3">

 

 

</LinearLayout>


17.activity_Sixth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/ic_launcher">

 

 

</LinearLayout>


18.activity_Seventh.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image7">

 

 

</LinearLayout>


19.activity_Eighth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image2">

 

 

</LinearLayout>


20.activity_Ninth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" 

    android:background="@drawable/image5">

 

 

</LinearLayout>


21.activity_Tenth.xml:


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:background="@drawable/image8" >

 

 

</LinearLayout>

No comments:

Post a Comment