Senin, 25 November 2013

Langkah - Langkah MultriScreen



LAPORAN
PEMROGRAMAN MOBILE
MULTISCREEN





Disusun Oleh :
Nama         : Rindi Fatimah
NIM : 12.12.0116


SKOLAH TINGGI  ILMU MANAJEMEN INFORMATIKA DAN KOMPUTER
AMIKOM PURWOKERTO
Jl .Let Jend. POL  SUMARTO Watumas Purwoneggoro Purwokerto 53113


LANGKAH – LANGKAH
MEMBUAT PROJECT MULTI SCREEN

Klik ganda pada icon eclipse pada desktop, kemudian tunggu hingga jendela eclipse  terbuka, lalu membuat project baru dengan cara klik file – pilih new – pilih Android Application Project.


Kemudian isikan nama project  Contoh
Application Name : Rindi’s maka di project Name akan menyesuaikan pada aplication namenya. Lalu pada Package Name hapus terlebih dahulu com.exclampe hingga titik lalu Next.




Lalu berikan simbol untuk tampilan yang akan kita buat
seperti pada gambar dibawah ini. Kemudian setelah selesai memberikan icon / simbol maka klik next .


Klik next hingga muncul tampilan seperti dibawah ini, lalu klik finish



Setelah kita selesai membuat project, maka kita lanjut untuk memulai membuat interface dengan pengcodingan pada activity_main.xml dengan mengetikan coding berikut :

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Selamat Datang Di Aplikasi Saya"
        android:textSize="14dp"
        android:textStyle="italic"
        android:typeface="serif" />

    <TextView
        android:id="@+id/textNama"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Nama Lengkap"
        android:textSize="12dp"
        android:textStyle="italic"
        android:typeface="serif" />
    <EditText
        android:id="@+id/editNama"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:typeface="serif" />

    <TextView
        android:id="@+id/textNIM"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="NIM"
        android:textSize="12dp"
        android:textStyle="italic"
        android:typeface="serif" />

    <EditText
        android:id="@+id/editNIM"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:typeface="serif" >

        <requestFocus />
    </EditText>
     <TextView
        android:id="@+id/textKelas"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Kelas "
        android:textSize="12dp"
        android:textStyle="italic"
        android:typeface="serif" />

    <EditText
        android:id="@+id/editKelas"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:typeface="serif" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textJenisKelamin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Jenis Kelamin"
        android:textSize="12dp"
        android:textStyle="italic"
        android:typeface="serif" />
    <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/radioLaki"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="Laki-Laki" />

        <RadioButton
            android:id="@+id/radioPerempuan"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Perempuan" />
       
    </RadioGroup>
   
        <Button
            android:id="@+id/btnOK"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="OK"
            android:textSize="14dp"
            android:textStyle="italic"
            android:typeface="serif" />
    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="38dp"
        android:src="@drawable/next" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Silahkan Klik Button Diatas"
        android:textSize="14dp"
        android:textStyle="italic"
        android:typeface="serif" />
   

</LinearLayout>
</ScrollView>

Lalu hasinya seperti berikut :


Setelah mengcoding di main_xml, lalu kita buat file xml baru dengan cara : Klik kana pilih New => android xml file lalu akan muncul tampilan berikut lalu isikan nama file xmlnya


Setelah file xmlnya dibuat lalu ketikan koding berikut :

<?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" >
   
    <ImageButton
        android:id="@+id/imagebutton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="14dp"
        android:onClick="pindah2"
        android:src="@drawable/back" />
   
      <TextView
        android:id="@+id/textBahasa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bahasa Yang Anda Kuasai"
        android:textSize="14dp" />
      <CheckBox
        android:id="@+id/checkJepang"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bahasa Jepang" />
     

    <CheckBox
        android:id="@+id/checkKorea"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bahasa Korea" />

    <CheckBox
        android:id="@+id/checkIndo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bahasa Indonesia" />

    <CheckBox
        android:id="@+id/checkIngg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bahasa Inggris" />

    <Button
        android:id="@+id/btnOK"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OK"
        android:textSize="14dp"
        android:textStyle="italic"
        android:typeface="serif" />
   

</LinearLayout>
  
Dan hasilnya adalah seperti berikut :


Setelah pembuatan user interfacenya selesai sekarang kita koding pada MainActivity dan SecondActivity:
MainActivity :


package example.rindis;

import example.rindis.R.id;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.Toast;

public class MainActivity extends Activity {
      private Button btnOk;
      private EditText editNama, editNIM, editKelas;
      private RadioButton rbLaki, rbPrp;
     

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        ImageButton startAct = (ImageButton)findViewById(R.id.imageButton1);

            editNama = (EditText)findViewById(R.id.editNama);
            editNIM = (EditText)findViewById(R.id.editNIM);
            editKelas= (EditText)findViewById(R.id.editKelas);
            btnOk = (Button)findViewById(R.id.btnOK);
            rbLaki = (RadioButton)findViewById(R.id.radioLaki);
            rbPrp = (RadioButton)findViewById(R.id.radioPerempuan);

            btnOk.setOnClickListener(new View.OnClickListener(){
                  public void onClick (View v){
                        if (rbLaki.isChecked()== true)
                        {
                              Toast.makeText(MainActivity.this, "Nama \t : "+editNama.getText().toString()+"\n"+
                        "Kelas\t : "+ editKelas.getText().toString()+"\n"+
                                          "NIM \t : "+editNIM.getText().toString()+ "\n"+
                        "Jenis Kelamin \t : "+" Laki - Laki",Toast.LENGTH_LONG).show();
                        }
                        else
                        {
                              Toast.makeText(MainActivity.this, "Nama \t : "+editNama.getText().toString()+"\n"+
                                          "Kelas\t : "+ editKelas.getText().toString()+"\n"+
                                                            "NIM \t : "+editNIM.getText().toString()+ "\n"+
                                          "Jenis Kelamin \t : "+" Perempuan",Toast.LENGTH_LONG).show();
                        }          
                  }
            });
           
        startAct.setOnClickListener(new View.OnClickListener() {
                 
                  @Override
                  public void onClick(View arg0) {
                        // TODO Auto-generated method stub
                        Intent myIntent = new Intent (getBaseContext(), SecondActivity.class);
                        startActivity(myIntent);
                  }
            });
    }
    public void pindah(View v){
      Intent pindah = new Intent(this, SecondActivity.class );
      startActivity(pindah);
    }
}

















SecondActivity :
package example.rindis;

import example.rindis.MainActivity;
import example.rindis.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.Toast;

public class SecondActivity  extends Activity{
      private Button btnOk;
      private CheckBox cbJepang, cbKorea, cbIndo, cbIngg;
      String bhasa="";
      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_second);
            ImageButton startAct = (ImageButton) findViewById(R.id.imagebutton1);
            cbJepang = (CheckBox)findViewById(R.id.checkJepang);
            cbKorea= (CheckBox)findViewById(R.id.checkKorea);
            cbIndo= (CheckBox)findViewById(R.id.checkIndo);
            cbIngg= (CheckBox)findViewById(R.id.checkIngg);
            btnOk = (Button)findViewById(R.id.btnOK);
           
            btnOk.setOnClickListener(new View.OnClickListener(){
                  public void onClick (View v)
                  {
                        if(cbJepang.isChecked()==true){
                              bhasa =bhasa+"\nBahasa Jepang ";
                        }
                        if(cbKorea.isChecked()==true){
                              bhasa = bhasa+"\nBahasa Korea";
                        }
                        if (cbIndo.isChecked()==true){
                              bhasa = bhasa+"\nBahasa Indonesia";
                        }
                        if(cbIngg.isChecked()==true){
                              bhasa =bhasa+ "\nBahasa Inggris";
                        }
                        Toast.makeText(getApplicationContext(),"Bahasa yang Anda kuasai adalah : "+bhasa, Toast.LENGTH_SHORT).show();
                  }
                  });
                 
            startAct.setOnClickListener(new View.OnClickListener() {

                  @Override
                  public void onClick(View v) {
                        // TODO Auto-generated method stub
                        Intent myIntent = new Intent(getBaseContext(),
                                    MainActivity.class);
                        startActivity(myIntent);
                  }
            });
      }
      public void pindah2(View V) {
            Intent pindah2 = new Intent(this, MainActivity.class);
            startActivity(pindah2);
      }
}


Lalu tambahkan activitynya pada manifest.xmlnya
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="example.rindis"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="example.rindis.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <activity
            android:name="example.rindis.SecondActivity"
            android:label="@string/app_name">
            <intent-filter >
                <action  android:name="android.intent.action.SECOND"/>
                <category android:name="android.intent.action.DEFAULT"/>
            </intent-filter>
               </activity>
    </application>


</manifest>

OUTPUT


Lalu klik button Next :

Tidak ada komentar:

Posting Komentar