Sabtu, 05 Oktober 2019

listview biodata dengan android studio


Assalamulaikum Wr.wb

Pada kesempatan ini saya akan membahas bagaimana cara membuat list view bio menggunakan android studio.
sehingga pada saat kita akan membuka bio akan muncul tampilan seperti di bawah ini dan jangan lupa persiapkan tools serta sourcecode untuk di gunakan ya.


lansung saja kita mulai langkah-langkahnya ya.

1. Buka aplikasi android studio dan buat project baru,kita buat form login terlebih dahulu .
pada activity_main.xml isi sourcode berikut. 

sourcode:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/colorPrimary"
    android:layout_height="match_parent"
    tools:context="com.endang.uilogin.MainActivity">

    <RelativeLayout
        android:layout_width="362dp"
        android:layout_height="358dp"
        android:layout_marginTop="44dp"
        android:layout_marginBottom="236dp"
        android:background="@color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/frameLayout"
        app:layout_constraintVertical_bias="1.0">

        <LinearLayout
            android:layout_width="323dp"
            android:layout_height="57dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_marginTop="77dp"
            android:layout_marginEnd="18dp"
            android:layout_marginRight="18dp"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/edUser"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:ems="10"
                android:hint="Username"
                android:inputType="textPersonName" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="320dp"
            android:layout_height="60dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginStart="23dp"
            android:layout_marginLeft="23dp"
            android:layout_marginTop="147dp"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

            <EditText
                android:id="@+id/edPassword"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:ems="10"
                android:hint="Password"
                android:inputType="textPassword" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="188dp"
            android:layout_height="48dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginStart="89dp"
            android:layout_marginLeft="89dp"
            android:layout_marginTop="213dp"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="210dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@color/orange"
                android:text="Login"
                android:textColor="@android:color/background_light" />
        </LinearLayout>

    </RelativeLayout>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="122dp"
        android:layout_height="109dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.491"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    </FrameLayout>

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="128dp"
        android:layout_height="98dp"
        android:src="@drawable/icon"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
tampilannya akan seperti gambar di bawah ini.




2.Ketika sudah membuat form login,yang akan di buat selanjutnya listview bio.
pada activity_home.xml isi kan sourecode berikut.

sourcecode:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.endang.uilogin.home">

    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

Tampilannya akan seperti gambar di bawah ini.


3. Selanjutnya buat biodata pada list bio yang sudah di buat.
pada welcomejava isi sourcode berikut.

Sourcode:

package com.endang.uilogin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class Welcome extends AppCompatActivity {

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

    }
}

Pada String.xml isi sourcode berikut.

Sourcode:

<resources>
    <string name="app_name">EndangSyanti-161021450089</string>
</resources>

Selanjutnya pada mainactivityjava isi sourcecode berikut.

Sourcecode:

package com.endang.uilogin;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    Button btLogin;
    TextView eUser, epass;
    String user, pass;


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

        btLogin = (Button) findViewById(R.id.btnLogin);
        eUser = (TextView) findViewById(R.id.edUser);
        epass = (TextView) findViewById(R.id.edPassword);

        btLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               user = eUser.getText().toString();
               pass = epass.getText().toString();

               Bundle b = new Bundle();
               b.putString("u" , user);
               b.putString("p" , pass);

               Intent in = new Intent(getBaseContext(), home.class);
               in.putExtras(b);
               startActivity(in);
            }
        });
    }
}

Tampilannya akan seperti ini.




4.Terakhir yaitu running.Maka tampil hasil runningnya adalah sebagai berikut.
a.Tampilan Login
b.Tampilan listview Bio
c.Tampilan hasil Bio


Nah..Demikian lah langkah-langkah sederhana dalam pembuatan list view bio pada android studio.mohon maaf apabila ada kesalahan dan kekurangan.Semoga dapat bermanfaat bagi kita semua.












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