Belajar Cara Membuat ListView dengan Android Studio
Selamat malam teman-teman , balik lagi di Blog saya yang ingin sedikit membagikan tentang pembuatan aplikasi menggunakan ListView pada Android Studio.
Icon Launcher Aplikasi
1. Pada Tahap awal terlebih dahulu buat Main Activity di File-new Project-buat nama MainActivity
Berikut Codingan MainActivity.java :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| package com.example.myapps;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText username, password;
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
btnLogin = (Button)findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String usernameKey = username.getText().toString();
String passwordKey = password.getText().toString();
if (usernameKey.equals("tata") && passwordKey.equals("4822")){
//jika login berhasil
Toast.makeText(getApplicationContext(), "LOGIN SUKSES",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, dashboard.class);
MainActivity.this.startActivity(intent);
finish();
}else {
//jika lo
//
// gin gagal
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Username atau Password Anda salah!")
.setNegativeButton("Retry", null).create().show();
}
}
});
}
}
|
2. Lalu berikutnya adalah Activity_main.xml nya
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_light"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true">
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_title"
android:layout_marginLeft="30dp"
android:layout_marginTop="70dp"
android:layout_marginRight="30dp"
android:background="#fff"
android:elevation="4dp"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="30dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/username"
android:hint="User Name"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:drawableLeft="@drawable/password"
android:hint="Password"
android:inputType="numberPassword" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:paddingTop="5dp"
android:text="Forgot Password?" />
<Button
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="22dp"
android:background="#d67601"
android:text="Sign in"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
<ImageButton
android:id="@+id/user_profile_photo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@+id/login_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="@drawable/background_porfile"
android:elevation="4dp"
android:src="@drawable/user_icon" />
<TextView
android:id="@+id/login_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="26dp"
android:gravity="center_horizontal"
android:text="Login "
android:textColor="#fff"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="2dp"
android:background="@color/colorAccent"
android:text="Created by : Dwi Septiana Maulida " />
</RelativeLayout>
|
3. Setelah di Run akan menampilkan form Login
4. Setelah berhasil Login maka akan Tampil Dashboard atau tampilan menu utama
5.Dibawah ini dashboard.xml nya
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
| <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:columnCount="2"
app:rowCount="2"
app:orientation="horizontal"
>
<FrameLayout
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#F38DB4"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="list"
android:id="@+id/user"
android:src="@drawable/profile"
/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_height="wrap_content"
android:layout_below="@+id/user"
android:layout_centerHorizontal="true"
android:text="Talent"/>
</RelativeLayout>
</FrameLayout>
<FrameLayout
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#D2691E">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="Job"
android:id="@+id/job"
android:src="@drawable/vancan"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_height="wrap_content"
android:layout_below="@+id/job"
android:layout_centerHorizontal="true"
android:text="Search Job"/>
</RelativeLayout>
</FrameLayout>
<FrameLayout
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#9797AD">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/notif"
android:onClick="alat"
android:src="@drawable/alat"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_height="wrap_content"
android:layout_below="@+id/notif"
android:layout_centerHorizontal="true"
android:text="Device"/>
</RelativeLayout>
</FrameLayout>
<FrameLayout
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#E2F2F6"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:onClick="onButtonTap"
android:id="@+id/mail"
android:src="@drawable/maile"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_height="wrap_content"
android:layout_below="@+id/mail"
android:layout_centerHorizontal="true"
android:text="Email"/>
</RelativeLayout>
</FrameLayout>
</android.support.v7.widget.GridLayout>
|
6. Selanjutnya dashboard.java nya adalah sebagai berikut :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| package com.example.myapps;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class dashboard extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
}
public void buka(View view) {
String url = "http://www.makna.net/";
Intent bukabrowser = new Intent(Intent.ACTION_VIEW);
bukabrowser.setData(Uri.parse(url));
startActivity(bukabrowser);
}
public void list(View view) {
Intent list = new Intent(dashboard.this, Liststaff.class);
startActivity(list);
}
public void alat(View view) {
Intent alat = new Intent(dashboard.this, device.class);
startActivity(alat);
}
public void Job(View view) {
Intent Job = new Intent(dashboard.this, findjob.class);
startActivity(Job);
}
public void onButtonTap(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"dseptiana07.dsm@gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Latihan Android Bareng TATA");
intent.putExtra(Intent.EXTRA_TEXT, "Hai, guys yuk latihan Android Studio bareng gw");
try {
startActivity(Intent.createChooser(intent, "Ingin Mengirim Email ?"));
} catch (android.content.ActivityNotFoundException ex) {
//do something else
}
}
}
|
7. Ketika user memilih talent pada dashboard maka akan muncul activity pilih Talent berikut ini :
8. Berikut ListView untuk menampilkan liststaff.java diatas :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
| package com.example.myapps;
import android.content.Intent;
import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;
public class Liststaff extends AppCompatActivity {
ListView LV;
String [] Menu1={"Haryanto S.Kom",
"Iin Marlina S.Kom","Rafica Sony S.Kom","Tria Widiawati SE","Riana Ayudia M.Kom","Tata S.Kom,M.Kom"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_liststaff);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
LV = (ListView) findViewById(R.id.list);
ArrayAdapter adapter = new ArrayAdapter (this,android.R.layout.simple_list_item_single_choice, Menu1);
LV.setAdapter(adapter);
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int itemke, long args3) {
String itemText=(String) LV.getItemAtPosition(itemke);
Toast.makeText(getBaseContext(),"Anda Mengklik" +itemText , Toast.LENGTH_LONG).show();
if(itemText.equals("Tata S.Kom,M.Kom")){
Intent haryantoIntent= new Intent (arg0.getContext(), staff1.class);
startActivityForResult(haryantoIntent,0);
}
if(itemText.equals("Haryanto S.Kom")){
Intent haryantoIntent= new Intent (arg0.getContext(), staff1.class);
startActivityForResult(haryantoIntent,0);
}
if(itemText.equals("Iin Marlina S.Kom")){
Intent haryantoIntent= new Intent (arg0.getContext(), staff1.class);
startActivityForResult(haryantoIntent,0);
}
if(itemText.equals("Rafica Sony S.Kom")){
Intent haryantoIntent= new Intent (arg0.getContext(), staff1.class);
startActivityForResult(haryantoIntent,0);
}
if(itemText.equals("Tria Widiawati SE")){
Intent haryantoIntent= new Intent (arg0.getContext(), staff1.class);
startActivityForResult(haryantoIntent,0);
}
}
});
}
}
|
9. Selanjutnya temen-temen buat Liststaff.xml sebagai desain pada aplikasi :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Liststaff">
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/list"
android:textSize="20px"></ListView>
</RelativeLayout>
|
10. Pada proses pemilihan talent akan ditujukan pada form permintaan talent :
11. Berikut coding Xmlnya pada form diatas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| <?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:orientation="vertical"
android:padding="30dp"
tools:context=".staff1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama PIC : "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/namapic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Company : "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/namacompany"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jumlah Hari "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/jumlahhari"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="number"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Venue "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/alamat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="text"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
<Button
android:id="@+id/tombol1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:text="PROSES"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="@+id/totaltagihan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="8dp"
android:text="Total Tagihan "
android:textColor="@color/colorAccent"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/keterangan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="Keterangan "
android:textColor="@color/colorAccent"
android:textSize="18dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/tombol2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:text="RESET"
android:textColor="#ffffFF"
android:textStyle="bold" />
<Button
android:id="@+id/tombol3"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="@color/colorPrimary"
android:text="EXIT"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
|
12. Selanjutnya buat codingan Javanya :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
| package com.example.myapps;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class staff1 extends AppCompatActivity {
private EditText edtnamapic, edtnamacom, edthari, edtalamat ;
private Button btnproses;
private Button btnhapus;
private Button btnexit;
private TextView txtnamapic;
private TextView txtnamacom;
private TextView txthari;
private TextView txtalamat;
private TextView txttotaltagihan;
private TextView txtketerangan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_staff1);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
edtnamapic = (EditText) findViewById(R.id.namapic);
edtnamacom = (EditText) findViewById(R.id.namacompany);
edthari = (EditText) findViewById(R.id.jumlahhari);
edtalamat = (EditText) findViewById(R.id.alamat);
btnproses = (Button) findViewById(R.id.tombol1);
btnhapus = (Button) findViewById(R.id.tombol2);
btnexit = (Button) findViewById(R.id.tombol3);
txtnamapic = (TextView) findViewById(R.id.namapic);
txtnamacom = (TextView) findViewById(R.id.namacompany);
txthari = (TextView) findViewById(R.id.jumlahhari);
txtalamat = (TextView) findViewById(R.id.alamat);
txttotaltagihan = (TextView) findViewById(R.id.totaltagihan);
txtketerangan = (TextView) findViewById(R.id.keterangan);
//memberikan action pada tombol proses
btnproses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String namapic = edtnamapic.getText().toString().trim();
String namacom = edtnamacom.getText().toString().trim();
String hari = edthari.getText().toString().trim();
String alamat = edtalamat.getText().toString().trim();
txtnamapic.setText("Terima kasih "+namapic);
int harga= 1000000;
Float h = Float.parseFloat(hari);
Float total = (h* harga);
txttotaltagihan.setText("Total Tagihan : RP." + total);
txtketerangan.setText("Jadi Total Tagihannya adalah RP "+total);
txtalamat.setText("Dengan Alamat "+alamat);
txtketerangan.setText("Keterangan : Segera Kami kirimkan Talent dan Invoicenya, Terima Kasih");
}
});
btnhapus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
txtnamapic.setText(" ");
txtnamacom.setText(" ");
txthari.setText(" ");
txtketerangan.setText(" ");
Toast.makeText(getApplicationContext(),"Data sudah direset", Toast.LENGTH_LONG).show();
// memberikan action pada tombol keluar
}
});
btnexit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
moveTaskToBack(true);
}
});
}
}
|
13. Pada dashboard ada pilihan untuk melamar pekerjaan dan berikut Form nya :
14. Berikut Coding Xml dan javanya :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| package com.example.myapps;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class findjob extends AppCompatActivity {
private EditText edtnamaleng, edtemail, edtttl, edtalamat ;
private Button btnproses;
private Button btnhapus;
private Button btnexit;
private TextView txtnamaleng;
private TextView txtemail;
private TextView txtttl;
private TextView txtalamat;
private TextView txtketerangan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_findjob);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
edtnamaleng = (EditText) findViewById(R.id.namaleng);
edtemail = (EditText) findViewById(R.id.email);
edtttl = (EditText) findViewById(R.id.ttl);
edtalamat = (EditText) findViewById(R.id.alamat);
btnproses = (Button) findViewById(R.id.tombol1);
btnhapus = (Button) findViewById(R.id.tombol2);
btnexit = (Button) findViewById(R.id.tombol3);
txtnamaleng = (TextView) findViewById(R.id.txtnamaleng);
txtemail = (TextView) findViewById(R.id.txtemail);
txtttl = (TextView) findViewById(R.id.txtttl);
txtalamat = (TextView) findViewById(R.id.alamat);
txtketerangan = (TextView) findViewById(R.id.keterangan);
//memberikan action pada tombol proses
btnproses.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String namaleng = edtnamaleng.getText().toString().trim();
String email = edtemail.getText().toString().trim();
String ttl = edtttl.getText().toString().trim();
String alamat = edtalamat.getText().toString().trim();
txtnamaleng.setText("Terima kasih sudah mengisi form lamaran pekerjaan di PT. Makna Karya Indonusa. "+namaleng);
txtketerangan.setText("Keterangan : Segera Kami proses dokumen anda, Terima kasih");
}
});
btnhapus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
txtnamaleng.setText(" ");
txtemail.setText(" ");
txtttl.setText(" ");
txtketerangan.setText(" ");
Toast.makeText(getApplicationContext(),"Data sudah direset", Toast.LENGTH_LONG).show();
// memberikan action pada tombol keluar
}
});
btnexit.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
moveTaskToBack(true);
}
});
}
}
|
Dan Ini XML nya
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
| <?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:orientation="vertical"
android:padding="30dp"
tools:context=".findjob">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtnamaleng"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama Lengkap : "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/namaleng"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtttl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tanggal lahir "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/ttl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="text"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtalamat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alamat "
android:textColor="@color/colorAccent"
android:textStyle="bold" />
<EditText
android:id="@+id/alamat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="text"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
<Button
android:id="@+id/tombol1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:text="PROSES"
android:textColor="#ffffff"
android:textStyle="bold" />
<TextView
android:id="@+id/keterangan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="Keterangan "
android:textColor="@color/colorAccent"
android:textSize="18dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/tombol2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:text="RESET"
android:textColor="#ffffFF"
android:textStyle="bold" />
<Button
android:id="@+id/tombol3"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="@color/colorPrimary"
android:text="EXIT"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
|
15. Pada dashboard juga terdapat pilihan Form Peminjaman Device
16. Untuk membuat form diatas berikut Xml dan Javanya
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
| <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout 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"
android:orientation="vertical"
android:padding="30dp"
tools:context=".form_alat">
<EditText
android:id="@+id/edt_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Masukan nama pemesan"
android:inputType="text"
android:textColor="@color/colorAccent"/>
<EditText
android:id="@+id/edt_com"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Masukan nama perusahaan"
android:inputType="text"
android:textColor="@color/colorAccent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pilih Kota"
android:textColor="@color/colorAccent"
android:textSize="25dp" />
<CheckBox
android:id="@+id/Jb_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:text="Jabodetabek"
android:textSize="15sp"
android:textColor="@color/colorAccent"/>
<CheckBox
android:id="@+id/Lj_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:text="Luar Jabodetabek"
android:textSize="15sp"
android:textColor="@color/colorAccent"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="@color/colorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Masukkan Jumlah alat"
android:textAllCaps="true"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textColor="@color/colorAccent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:onClick="decrement"
android:text="-" />
<TextView
android:id="@+id/quantity_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="0"
android:textColor="@color/colorAccent"
android:textSize="25dp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@color/colorPrimary"
android:onClick="increment"
android:text="+" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="@color/colorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Total tagihan"
android:textAllCaps="true"
android:textSize="30dp"
android:textColor="@color/colorAccent"/>
<TextView
android:id="@+id/price_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="@color/colorAccent"
android:textSize="25dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="@color/colorPrimary"
android:onClick="Submitorder"
android:text="PROSES" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:onClick="exit"
android:text="Close" />
</LinearLayout>
</ScrollView>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| package com.example.myapps;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.text.NumberFormat;
import static android.R.string.no;
import static android.os.Build.VERSION_CODES.N;
/**
* This app displays an order form to order coffee.
*/
public class device extends AppCompatActivity {
Button btnExit;
int quantity=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device);
getSupportActionBar().setTitle("MAKNA TRANSLATION");
}
public void increment(View view){//function tombol tambah
if(quantity==200){
Toast.makeText(this,"pesanan maximal 200",Toast.LENGTH_SHORT).show();
return;
}
quantity = quantity+1 ;
display(quantity);
}
public void decrement(View view){//function kurang
if (quantity==1){
Toast.makeText(this,"pesanan minimal 1",Toast.LENGTH_SHORT).show();
return;
}
quantity = quantity -1;
display(quantity);
}
public void Submitorder(View view) {
EditText nameEditText=(EditText)findViewById(R.id.edt_name);
String name=nameEditText.getText().toString();
Log.v("form_alat","Nama:"+name);
EditText comEditText=(EditText)findViewById(R.id.edt_com);
String company=nameEditText.getText().toString();
Log.v("form_alat","Perusahaan:"+company);
CheckBox jaboChekBox= (CheckBox) findViewById(R.id.Jb_checkbox);
boolean hasjabo=jaboChekBox.isChecked();//mengidentifikasi check jabodetabek
Log.v("form_alat","has whippedcream:"+hasjabo);
CheckBox lujaChekBox= (CheckBox) findViewById(R.id.Lj_checkbox);
boolean hasluja=lujaChekBox.isChecked();//mengidentifikasi check luar jabodatek
Log.v("form_alat","has whippedcream:"+hasluja);
int price=calculateprice(hasjabo,hasluja);//memanggil method jumlah harga
String pricemessage=createOrderSummary(price,name,company,hasjabo,hasluja);
displayMessage(pricemessage);
}
private int calculateprice(boolean addjabo,boolean addluja){
int harga=100000;
if(addjabo){
harga=harga+150000;//harga tambahan transport
}
if (addluja){
harga=harga+300000;
}
return quantity * harga;
}
private String createOrderSummary(int price, String name, String company, boolean addChocolate, boolean addWhippedCream) {//hasil pemesanan
String pricemessage=" Dear "+name;
pricemessage+="\n Jumlah Pemesanan Adalah =" +quantity;
pricemessage+="\n Dengan Total Tagihan = Rp " +price;
pricemessage+="\n Terimakasih, salam sukses.. ";
return pricemessage;
}
//method ini untuk mencetak hasil perintah yang di tampilkan dengan inisial quantity_textview di textview 0
private void displayMessage(String message) {
TextView priceTextView = (TextView) findViewById(R.id.price_textview);
priceTextView.setText(message);
}
private void display(int number) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_textview);
quantityTextView.setText("" + number);
}
private void displayPrice(int number) {
TextView priceTextView = (TextView) findViewById(R.id.price_textview);
priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
}
}
|
17. Pilihan terakhir adalah Email, pada email ini user bisa langsung terhubung ke pilihan kirim pesan. Pada tutorial ini saya tampilkan langsung ke gmail dan ini tampilan pada Gmailnya .
18. Pada tahapan ini temen-temen menambahkan codingan berikut di dashboard javanya :
1
2
3
4
5
6
7
8
9
10
11
12
| public void onButtonTap(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"dseptiana07.dsm@gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Latihan Android Bareng TATA");
intent.putExtra(Intent.EXTRA_TEXT, "Hai, guys yuk latihan Android Studio bareng gw");
try {
startActivity(Intent.createChooser(intent, "Ingin Mengirim Email ?"));
} catch (android.content.ActivityNotFoundException ex) {
//do something else
}
|
Terima kasih temen-temen dan Pak Agus Suharto selaku dosen Mata Kuliah Mobile Programming yang sudah banyak memberi masukan dan pengenalan tentang software Android Studio.
Mohon maaf jika banyak kesalahan pada aplikasi yang saya buat, jika berkenan mohon beri masukan pada kolom komentar.
SALAM SUKSES
"CODING IS FUN"
Habis pusing ngoding jangan lupa refreshing, yuk kapan-kapan naik gunung bareng guys.
Jangan lupa tonton yuoutube chanel gw di beberapa gunung yang pernah gw daki.
Link :