lanjut ke tutorial ke tiga

pada tutorial ini membuat form registrasi.java

package com.aplikasimotor;

import driver.Utils;
import driver.XMLParser;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;

public class registrasi extends Activity {
XMLParser parser = new XMLParser();
String username,password,nama,alamat,telepon;
EditText txtTelepon,txtNama,txtUser,txtPass,txtAlamat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registrasi);

txtPass=(EditText)findViewById(R.id.regpassword);
txtUser=(EditText)findViewById(R.id.regusername);

txtNama=(EditText)findViewById(R.id.regnama);
txtTelepon=(EditText)findViewById(R.id.regtelp);
txtAlamat=(EditText)findViewById(R.id.regalamat);

Button  btnReg=(Button)findViewById(R.id.regRegistrasi);
btnReg.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {

username=txtUser.getText().toString();
password=txtPass.getText().toString();
telepon=txtTelepon.getText().toString();
nama=txtNama.getText().toString();
alamat=txtAlamat.getText().toString();

username=username.replaceAll(” “, “_”);
password=password.replaceAll(” “, “_”);
telepon=telepon.replaceAll(” “, “_”);
nama=nama.replaceAll(” “, “_”);
alamat=alamat.replaceAll(” “, “_”);

Utils ip=new Utils();
String myip=ip.getIP();
String URL = myip+”android/registrasi.php?nama_customer=”+nama+”&username=”+username+”&password=”+password+”&telepon=”+telepon+”&alamat=”+alamat+”&ket=ok”;
String xml = parser.getXmlFromUrl(URL);

if(xml.indexOf(“sukses”)>=0){
sukses();
}
else{
gagal();
}

}});
Button  btnKembali=(Button)findViewById(R.id.regBatal);
btnKembali.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
finish();
}});

}

public void pesan(String ps){
new AlertDialog.Builder(this)
.setTitle(“Pesan”)
.setMessage(ps)
.setNeutralButton(“Tutup”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
}})
.show();
}

public void lengkapi(String lkp){
new AlertDialog.Builder(this)
.setTitle(“Silakan Isi data”)
.setMessage(“Maaf, Silakan isi “+lkp)
.setNeutralButton(“Tutup”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
}})
.show();
}
//——————————————————————————————-
public void sukses(){
new AlertDialog.Builder(this)
.setTitle(“Sukses Simpan Registrasi”)
.setMessage(“Terimakasih anda telah melakukan pendaftaran….”)
.setNeutralButton(“Tutup”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
finish();
}})
.show();
}

public void gagal(){
new AlertDialog.Builder(this)
.setTitle(“Registasri Anggota Gagal”)
.setMessage(“Update Biodata gagal silakan cek jaringan….”)
.setNeutralButton(“OK”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {

}})
.show();
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
registrasi.xml

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" 
  android:background = "#000000" 
  android:orientation="vertical">
  
  
<TableLayout
android:layout_width = "wrap_content"
android:layout_height= "wrap_content"
android:orientation = "vertical"
>

    
</TableLayout>         

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="7dp"
    android:layout_marginRight="7dp"
    android:layout_marginTop="20dp"
    android:background="@drawable/hitam"
    android:orientation="vertical" >
    
<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="50dip"
    android:background="@drawable/hitam" >

<TableLayout
    android:id="@+id/TableLayout01"
   android:layout_width = "wrap_content"
android:layout_height= "wrap_content"
android:orientation = "vertical"


    >
<TableRow>
      <TextView
          android:text=""
          android:textColor="#ffffff"
          android:textSize="15dp" 
            android:layout_marginLeft="30dp" />

</TableRow>  
<TableRow>
      <TextView
          android:text=""
          android:textColor="#ffffff"
          android:textSize="15dp" 
            android:layout_marginLeft="30dp" />

</TableRow>


    
<TableRow android:id="@+id/TableRow00" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <TextView
          android:text="Nama "
          android:textColor="#ffffff"
          android:textSize="15dp"
          android:layout_marginLeft="30dp" />

      <EditText
          android:id="@+id/regnama"
          android:textColor="#ffffff"
          android:layout_marginLeft="30dp" />

</TableRow>    


<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <TextView
          android:text="Alamat"
          android:textColor="#ffffff"
          android:textSize="15dp"
          android:layout_marginLeft="30dp" />

      <EditText
          android:id="@+id/regalamat"
          
          android:textColor="#ffffff"
          android:minLines="2"
          android:maxLines="3"
          
          android:layout_marginLeft="30dp" />

          <requestFocus />
      

</TableRow>  
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <TextView
          android:text="Telepon"
          android:textColor="#ffffff"
          android:textSize="15dp"
          android:layout_marginLeft="30dp" />

      <EditText
          android:id="@+id/regtelp"
          android:textColor="#ffffff"
          android:layout_marginLeft="30dp" />

</TableRow>   

<TableRow android:id="@+id/TableRow00" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <TextView
          android:text="Username "
          android:textColor="#ffffff"
          android:textSize="15dp"
          android:layout_marginLeft="30dp" />

      <EditText
          android:id="@+id/regusername"
          android:textColor="#ffffff"
          android:layout_marginLeft="30dp" />

</TableRow>    
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <TextView
          android:text="Password"
          android:textColor="#ffffff"
          android:textSize="15dp"
          android:layout_marginLeft="30dp" />

      <EditText
          android:id="@+id/regpassword"
          android:inputType="textPassword"
          android:textColor="#ffffff"
          android:layout_marginLeft="30dp" />

</TableRow>    
 
<TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content" android:layout_height="wrap_content">    

      <Button
          android:id="@+id/regRegistrasi"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Registrasi"
          android:layout_marginLeft="40dp" />
</TableRow>    
<TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content" android:layout_height="wrap_content">    

  <Button
      android:id="@+id/regBatal"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="Kembali"
      android:visibility="visible"
      android:layout_marginLeft="40dp" />
</TableRow>
</TableLayout>
</ScrollView>

</LinearLayout>  
</LinearLayout>

tampilan form registrasi menggunakan table layout

penjualan3
Penjualan online for android part 4
Penjualan online for android part 2
Chat with Ranto