Minggu, 22 September 2019

Membuat form bidoata mahasisa dengan eclipse

 Assalamualaikum wr.wb



  Pada kesempatan Kali ini saya akan  membuat aplikasi Biodata Mahasiswa sederhana .agar mahiswa dapat mengisi data dengan mudah.


Oke langsung saja kita mulai

1.Pertama kita buat project kita dulu buka aplikasi eclipse lalu pilih new dan pilih new project android,isi nama sesuai yang di inginkan.







3.Setelah itu akan muncul tampilan seperti ini.
4.lalu kita buat main activity nya.
1.Activity_main.xml desain login dan desian form biodatanya

<RelativeLayoutxmlns: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" >

    <LinearLayout
        android:id="@+id/linearLayout1"     
        android:layout_width="wrap_content"     
        android:layout_height="wrap_content"     
        android:layout_alignParentLeft="true"     
        android:layout_alignParentRight="true"     
        android:layout_alignParentTop="true" >

        <TextView
            android:id="@+id/textView1"         
            android:layout_width="match_parent"         
            android:layout_height="wrap_content"         
            android:gravity="center"         
            android:text="Form Login"
            android:textAppearance="?android:attr/textAppearanceMedium"
/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"     
        android:layout_width="wrap_content"     
        android:layout_height="wrap_content"     
        android:layout_alignParentLeft="true"     
        android:layout_alignParentRight="true"     
        android:layout_below="@+id/linearLayout1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView2"         
            android:layout_width="match_parent"         
            android:layout_height="wrap_content"         
            android:text="User Name" />

        <EditText
            android:id="@+id/userNameEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="User Name" >

            <requestFocus />
        </EditText>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"     
        android:layout_width="wrap_content"     
        android:layout_height="wrap_content"     
        android:layout_alignParentLeft="true"     
        android:layout_alignParentRight="true"     
        android:layout_below="@+id/linearLayout2"     
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView3"         
            android:layout_width="match_parent"         
            android:layout_height="wrap_content"         
            android:text="Password" />

        <EditText
            android:id="@+id/passwordEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:inputType="textPassword" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"     
        android:layout_height="wrap_content"     
        android:layout_alignParentLeft="true"     
        android:layout_alignParentRight="true"     
        android:layout_below="@+id/linearLayout3" >

        <Button
            android:id="@+id/loginButton"         
            android:layout_width="wrap_content"         
            android:layout_height="wrap_content"         
            android:layout_weight="3"         
            android:text="Login" />

        <Button
            android:id="@+id/tutupButton"         
            android:layout_width="wrap_content"         
            android:layout_height="wrap_content"         
            android:layout_weight="1"         
            android:text="Tutup" />

    </LinearLayout>
    </RelativeLayout>

    2). Setelah itu kita buat tampilannya terlebih dahulu pada file actifity_main.xml. sourcecode berikut kefile xml.

 </RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android&#8221;
xmlns:tools=“http://schemas.android.com/tools&#8221;
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=“.MainActivity” >

<TableLayout
android:id=“@+id/tablelayout1”
android:layout_width=“fill_parent”
android:layout_height=“match_parent” >

<TextView
android:id=“@+id/textView1”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“NIM”
android:textAppearance=“?android:attr/textAppearanceMedium”
/>

<EditText
android:id=“@+id/editView1”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_marginBottom=“20px”
android:ems=“10”
android:inputType=“textPersonName”
/>

<TextView
android:id=“@+id/textView2”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Nama Lengkap”
android:textAppearance=“?android:attr/textAppearanceMedium”
/>

<EditText
android:id=“@+id/editView2”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_marginBottom=“20px”
android:ems=“10”
android:inputType=“textPersonName”
/>

<TextView
android:id=“@+id/textView3”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Jurusan”
android:textAppearance=“?android:attr/textAppearanceMedium”
/>

<RadioGroup
android:id=“@+id/radioGroup1”
android:layout_width=“fill_parent”
android:layout_height=“wrap_content”
android:layout_marginBottom=“20px” >


<RadioButton
android:id=“@+id/radioButton1”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Teknik Informatika”
/>

<RadioButton
android:id=“@+id/radioButton2”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Teknologi Hasil Pertanian”
/>

<RadioButton
android:id=“@+id/radioButton2”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Mesin dan Peralatan Pertanian”
android:layout_marginBottom=“20px”
/>
</RadioGroup>

<TextView
android:id=“@+id/textView4”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Semester”
android:textAppearance=“?android:attr/textAppearanceMedium”
/>

<Spinner
android:id=“@+id/spinner1”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_marginBottom=“20px”
android:drawSelectorOnTop=“true” />

<TextView
android:id=“@+id/textView5”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“Kelas”
android:textAppearance=“?android:attr/textAppearanceMedium”
/>

<Spinner
android:id=“@+id/spinner2”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_marginBottom=“20px”
android:drawSelectorOnTop=“true” />

</TableLayout>


 </RelativeLayout>

 3.Kemudian buat prosesnya pada file MainActifity. Java.  sourcecode dibawah ini .
package com.example.endangsuyanti;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

public class MainActivity extends Activity {

String[] semester = {
“– semester –“,
“1”,
“2”,
“3”,
“4”,
“5”,
“6”,
};

Spinner s1;


String[] kelas = {
” — kelas –“,
“A”,
“B”,
“C”,
“D”,

};

Spinner s2;


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


s1 = (Spinner) findViewById(R.id.spinner1);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, semester);

s1.setAdapter(adapter);
s1.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0,
View arg1, int arg2, long arg3)
{
int index = s1.getSelectedItemPosition();
Toast.makeText(getBaseContext(),
“You have selected item : ” + semester[index],
Toast.LENGTH_SHORT).show();
}

public void onNothingSelected(AdapterView<?> arg0) {}
});




s2 = (Spinner) findViewById(R.id.spinner2);

ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, kelas);

s2.setAdapter(adapter2);
s2.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0,
View arg1, int arg2, long arg3)
{
int index = s2.getSelectedItemPosition();
Toast.makeText(getBaseContext(),
“You have selected item : ” + kelas[index],
Toast.LENGTH_SHORT).show();
}

public void onNothingSelected(AdapterView<?> arg0) {}
});
}



@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;
}

}

5ketika semua source sudah benar .Saatnya Run Projectnya, klik pojok kanan untuk memunculkan menu






Tidak ada komentar:

Posting Komentar