Beberapa contoh program untuk membuat aplikasi sederhana untuk android, tapi sebelumnya pelajari dulu bagaimana cara membuat programnya 
disini. Jika sudah bisa sekarang silahkan di coba beberapa cooding program di bawah ini, dan lihat hasilnya...
 Contoh Program Android Sederhana Input Output
Contoh Program Android Sederhana Input Output
Berikut contoh file main.xml saya
| 01 | <?xmlversion="1.0"encoding="utf-8"?> | 
 
| 02 | <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" | 
 
| 03 |     android:layout_width="fill_parent" | 
 
| 04 |     android:layout_height="fill_parent" | 
 
| 05 |     android:gravity="center_horizontal" | 
 
| 06 |     android:orientation="vertical"> | 
 
| 09 |         android:id="@+id/tvInput" | 
 
| 10 |         android:layout_width="wrap_content" | 
 
| 11 |         android:layout_height="wrap_content" | 
 
| 12 |         android:text="Inputkan Teks"/> | 
 
| 15 |         android:id="@+id/etInput" | 
 
| 16 |         android:layout_width="match_parent" | 
 
| 17 |         android:layout_height="wrap_content"> | 
 
| 21 |         android:id="@+id/btnTampil" | 
 
| 22 |         android:layout_width="100dp" | 
 
| 23 |         android:layout_height="wrap_content" | 
 
| 24 |         android:text="Tampilkan"/> | 
 
| 27 |         android:id="@+id/btnExit" | 
 
| 28 |         android:layout_width="100dp" | 
 
| 29 |         android:layout_height="wrap_content" | 
 
| 30 |         android:text="Exit"/> | 
 
| 33 |         android:id="@+id/tvTampil" | 
 
| 34 |         android:layout_width="wrap_content" | 
 
| 35 |         android:layout_height="wrap_content" | 
 
 
 
Saya menggunakan 2 buah TextView dan dua buah Tombol dan 1 buah EditText, untuk file activitynya dibawah ini
| 01 | packageid.jay.emrs.tutor.inputoutput; | 
 
| 03 | importandroid.app.Activity; | 
 
| 04 | importandroid.graphics.Color; | 
 
| 05 | importandroid.os.Bundle; | 
 
| 06 | importandroid.view.View; | 
 
| 07 | importandroid.view.View.OnClickListener; | 
 
| 08 | importandroid.widget.Button; | 
 
| 09 | importandroid.widget.EditText; | 
 
| 10 | importandroid.widget.TextView; | 
 
| 12 | publicclassMainActivity extendsActivity implementsOnClickListener { | 
 
| 13 |     Button btnTampil, btnExit; | 
 
| 17 |     /** Called when the activity is first created. */ | 
 
| 19 |     publicvoidonCreate(Bundle savedInstanceState) { | 
 
| 20 |         super.onCreate(savedInstanceState); | 
 
| 21 |         setContentView(R.layout.main); | 
 
| 26 |     privatevoidinitialize() { | 
 
| 28 |         btnTampil = (Button) findViewById(R.id.btnTampil); | 
 
| 29 |         btnExit = (Button) findViewById(R.id.btnExit); | 
 
| 30 |         etInput = (EditText) findViewById(R.id.etInput); | 
 
| 31 |         tvTampil = (TextView) findViewById(R.id.tvTampil);       | 
 
| 32 |         btnTampil.setOnClickListener(this); | 
 
| 33 |         btnExit.setOnClickListener(this); | 
 
| 37 |     publicvoidonClick(View v) { | 
 
| 42 |             tvTampil.setText(etInput.getText().toString()); | 
 
| 44 |             tvTampil.setTextSize(36); | 
 
| 46 |             tvTampil.setTextColor(Color.CYAN); | 
 
 
 
 
0 Comment "Contoh program android"
Post a Comment