Berikut beberapa kode program dalam pembuatan aplikasi
Berikut adalah contoh kode program sederhana dalam pembuatan aplikasi menggunakan beberapa bahasa pemrograman populer:
Bahasa Pemrograman Java untuk Android
```
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button tombol = findViewById(R.id.tombol);
tombol.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Tombol ditekan!", Toast.LENGTH_SHORT).show();
}
});
}
}
```
Bahasa Pemrograman Swift untuk iOS
```
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tombol = UIButton(frame: CGRect(x: 100, y: 100, width: 200, height: 50))
tombol.setTitle("Tekan Saya", for: .normal)
tombol.backgroundColor = .blue
tombol.addTarget(self, action: #selector(tombolDitekan), for: .touchUpInside)
view.addSubview(tombol)
}
@objc func tombolDitekan() {
print("Tombol ditekan!")
}
}
```
Bahasa Pemrograman Python untuk Desktop
```
import tkinter as tk
def tombol_ditekan():
print("Tombol ditekan!")
root = tk.Tk()
root.title("Aplikasi Sederhana")
tombol = tk.Button(root, text="Tekan Saya", command=tombol_ditekan)
tombol.pack()
root.mainloop()
```
Kode program di atas hanya contoh sederhana dan dapat dikembangkan lebih lanjut untuk membuat aplikasi yang lebih kompleks dan menarik.
Komentar
Posting Komentar