MEMBUAT APP ANDROID “INPUT NAMA” MENGGUNAKAN ECLIPSE
MEMBUAT APLIKASI
“INPUT NAMA” MENGGUNAKAN ECLIPSE
MEMBUAT APLIKASI
“INPUT NAMA” MENGGUNAKAN ECLIPSE
Langsung saja Untuk membuatnya simak langkah – langkah nya
berikut ini :
1.
Buka Eclipse, lalu buat project baru
Setelah itu Beri nama projectnya
Jika sudah tinggal klikk next sampai Finish
4. Selamjutnya adalah membuat layout pada aplikasi yang akan di buat yang terletak pada :
3.
5.
Double Click pada activity_main.xml diatas dan klik
juga activity_main.xml disamping graphical layout
6.
ubah koding menjadi seperti berikut :
<RelativeLayout 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: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" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Masukan Nama :" />
<EditText
android:id="@+id/txtnama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="22dp"
android:ems="10" />
<Button
android:id="@+id/btntampil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtnama"
android:layout_below="@+id/txtnama"
android:layout_marginTop="30dp"
android:text="TAMPILKAN" />
<TextView
android:id="@+id/txttampil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btntampil"
android:layout_below="@+id/btntampil"
android:layout_marginLeft="14dp"
android:textSize="20px"
android:layout_marginTop="36dp"
android:text="HASIL" />
</RelativeLayout>
7.
Setelah itu Pada package explorer kesuk ke:
8.
Double click dan masukan koding berikut :
package com.ana.texsnama;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity
{
EditText x;
Button y;
TextView z;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
x=(EditText)findViewById(R.id.txtnama);
y=(Button)findViewById(R.id.btntampil);
z=(TextView)findViewById(R.id.txttampil);
y.setOnClickListener(new View.OnClickListener() {
@Override
public
void onClick(View arg0) {
//
TODO Auto-generated method stub
//yg
terjadi saat tbl di klik
z.setText(x.getText());
}
});
}
@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;
}
}
9. Setelah
itu run project dan inilah hasilnya:
Komentar
Posting Komentar