• Uncategorized
  • 0

Latihan M3 PAB

Tugas 1: Menambahkan beberapa tampilan teks

 

Tugas 2: Menambahkan tautan Web aktif dan ScrollView

2.1 Menambahkan atribut autoLink untuk tautan web aktif

2.2 Menambahkan ScrollView ke layout

 

Tugas 3: Menggulir beberapa elemen

3.1 Menambahkan LinearLayout ke ScrollView

Source Code : activity_main.xml

<?xml version=”1.0″ encoding=”utf-8″?>

<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”

    tools:context=”com.example.android.scrollingtext.MainActivity”>

 

    <TextView

        android:id=”@+id/article_heading”

        android:layout_width=”match_parent”

        android:layout_height=”wrap_content”

        android:background=”@color/colorPrimary”

        android:textColor=”@android:color/white”

        android:paddingTop=”10dp”

        android:paddingBottom=”10dp”

        android:paddingLeft=”10dp”

        android:paddingRight=”10dp”

        android:textAppearance=”@android:style/TextAppearance.Large”

        android:textStyle=”bold”

        android:text=”@string/article_title”/>

 

    <TextView

        android:id=”@+id/article_subheading”

        android:layout_width=”match_parent”

        android:layout_height=”wrap_content”

        android:layout_below=”@id/article_heading”

        android:paddingTop=”10dp”

        android:paddingBottom=”10dp”

        android:paddingLeft=”10dp”

        android:paddingRight=”10dp”

        android:textAppearance=”@android:style/TextAppearance”

        android:text=”@string/article_subtitle”/>

 

    <ScrollView

        android:layout_width=”wrap_content”

        android:layout_height=”wrap_content”

        android:layout_below=”@id/article_subheading”>

 

        <LinearLayout

            android:layout_width=”match_parent”

            android:layout_height=”wrap_content”

            android:orientation=”vertical”>

 

 

        <TextView

            android:id=”@+id/article”

            android:layout_width=”wrap_content”

            android:layout_height=”wrap_content”

            android:lineSpacingExtra=”5sp”

            android:layout_below=”@id/article_subheading”

            android:autoLink=”web”

            android:text=”@string/article_text”/>

        </LinearLayout>

    </ScrollView>

</RelativeLayout>

 

Dimens.xml

<resources>

<dimen name=“activity_horizontal_margin”>16dp</dimen>
<dimen
name=“activity_vertical_margin”>16dp</dimen>
<dimen
name=“padding_regular”>10dp</dimen>
<dimen
name=“line_spacing”>5sp</dimen>

</resources>

 

 

 

String.xml

<resources>

    <string name=”app_name”>Scrolling Text</string>

    <string name=”article_title”>Beatles Anthology Vol. 1</string>

    <string name=”article_subtitle”>Behind That Locked Door: Beatles Rarities!</string>

    <string name=”article_text”>In a vault deep inside Abbey Road Studios in London — protected by an unmarked, triple-locked, police-alarmed door — are something like 400 hours of unreleased Beatles recordings, starting from June 2, 1962 and ending with the very last tracks recorded for the <i>Let It Be</i> album. The best of the best were released by Apple Records in the form of the 3-volume Anthology series.

        For more information, see the Beatles Time Capsule at www.rockument.com.

\n\n

This volume starts with the first new Beatle song, “Free as a Bird” (based on a John Lennon demo, found only on the bootleg <i>The Lost Lennon Tapes Vol. 28</i>, and covers the very earliest historical recordings, outtakes from the first albums, and live recordings from early concerts and BBC Radio sessions.

\n\n

<b>Highlights include:</b>

\n\n

<b><i>Cry for a Shadow</i></b> – Many a Beatle fanatic started down the bootleg road, like I did, with a first listen to this song. Originally titled “Beatle Bop” and recorded in a single session that yielded four songs (the other three featured Tony Sheridan with the Beatles as a backing band), “Cry for a Shadow” is an instrumental written by Lennon and Harrison, which makes it unique to this day. John Lennon plays rhythm guitar, George Harrison plays lead guitar, Paul McCartney plays bass, and Pete Best plays drums. The sessions were produced by Bert Kaempfert in Hamburg, Germany, during the Beatles’ second visit from April through July of 1961 to play in the Reeperbahn-section clubs.

\n\n

<b><i>My Bonnie</i></b> and <b><i>Ain’t She Sweet</i></b> — At the same session, the Beatles played on “My Bonnie” (the first-ever single with Beatles playing), as the backing band for English singer Tony Sheridan, originally a member of the Jets. The popularity of this single in Liverpool brought the Beatles to the attention of Brian Epstein, who worked in the NEMS record store and tried to meet demand for the disc. John Lennon then sings a fine “Ain’t She Sweet” (his first-ever released vocal).

\n\n

<b><i>Searchin</i></b> — A Jerry Leiber – Mike Stoller comedy song that was a hit for the Coasters in 1957, and a popular live favorite of the Beatles. The Coasters also had a hit with “Besame Mucho” and the Beatles covered that song as well. Ringo Starr had by now replaced Pete Best on drums. The high falsetto is George, who also plays a hesitant lead guitar. This is from their first audition for Decca Records in London on Jan 1., 1962, live in the studio. The Grateful Dead would later cover “Searchin” with a similar arrangement, Pigpen doing the Paul vocals. A live version is available on bootlegs featuring the Dead joined by the Beach Boys!

\n\n

<b><i>Love Me Do</i></b> — An early version of the song, played a bit slower and with more of a blues feeling, and a cool bossa-nova beat in middle. Paul had to sing while John played harmonica — a first for the group. Pete Best played drums on this version.

\n\n

<b><i>She Loves You – Till There Was You – Twist and Shout</i></b> — Live at the Princess Wales Theatre by Leicester Square in London, attended by the Queen. “Till There Was You” (by Meredith Wilson) is from the musical The Music Man and a hit for Peggy Lee in 1961. Before playing it, Paul said it was recorded by his favorite American group, “Sophie Tucker” (which got some laughs). At the end, John tells the people in the cheaper seats to clap their hands, and the rest to “rattle your jewelry” and then announces “Twist and Shout” (a song by Bert Russell and Phil Medley that was first recorded in 1962 by the Isley Brothers). A film of the performance shows the Queen smiling at John’s remark.

\n\n

<b><i>Leave My Kitten Alone</i></b> — One of the lost Beatle songs recorded during the “Beatles For Sale” sessions but never released. This song, written by Little Willie John, Titus Turner, and James McDougal, was a 1959 R&amp;B hit for Little Willie John and covered by Johnny Preston before the Beatles tried it and shelved it. A reference to a “big fat bulldog” may have influenced John’s “Hey Bulldog” (Yellow Submarine album), which is a similar rocker.

\n\n

<b><i>One After 909</i></b> — A song recorded for the <i>Let It Be</i> album was actually worked on way back in the beginning, six years earlier. This take shows how they did it much more slowly, with an R&amp;B feel to it.

</string>

</resources>

 

MainActivity.java

package com.example.user.tugasscrolling;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

    }

}

2.1: Membuat dan Memulai Aktivitas

Tugas 1. Membuat proyek TwoActivities

1.      Mulai Android Studio dan buat proyek Android Studio baru.

Panggil aplikasi “TwoActivities” dan ubah domain perusahaan ke “android.example.com.” Pilih SDK Minimum yang Anda gunakan di proyek sebelumnya.

2.      Pilih Empty Activity untuk template proyek. Klik Next.

3.      Terima nama aktivitas default (MainActivity). Pastikan kotak Generate Layout file dicentang. Klik Finish.

1.2 Definisikan layout untuk aktivitas utama

1.3 Mendefinisikan tindakan tombol

Activity_main.xml

<?xml version=”1.0″ encoding=”utf-8″?>

<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”

    tools:context=”com.example.user.twoactivities.MainActivity”>

 

    <Button

        android:layout_width=”wrap_content”

        android:layout_height=”wrap_content”

        android:text=”@string/button_main”

        android:id=”@+id/button_main”

        android:layout_alignParentBottom=”true”

        android:layout_alignParentRight=”true”

        android:layout_alignParentEnd=”true”

        android:onClick=”launchSecondActivity”/>

</RelativeLayout>

 

MainActivity.java

package com.example.user.twoactivities;

 

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

 

public class MainActivity extends AppCompatActivity {

 

    private static final String LOG_TAG = MainActivity.class.getSimpleName();

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

    }

 

    public void launchSecondActivity(View view) {

        Log.d(LOG_TAG, “Button clicked!”);

    }

}

 

 

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *