This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Selasa, 02 Januari 2018

Cara Membuat Form Input Untuk Perawatan Berbasis Android

Pada laporan kali ini saya akan menjelaskan cara-cara membuat form input untuk setiap perawatan berbasis Android :

1. Buat class pendaftaran_operator.java
package thefly.org;

import go_antri.org.R;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;

import thefly.org.histori.HistoriFragmentActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;


public class pendaftaran_operator1 extends Activity {
 
EditText nama,umur,alamat,penyakit;
RadioGroup jk;
TextView status, tampilkan;
Button daftar;
     
    /** Called when the activity is first created. */
    @Override
     
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pendaftaran_operator1);
       
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
      }
       
        nama=(EditText)findViewById(R.id.txtnamapasien1);
        jk=(RadioGroup) findViewById(R.id.jekel_operator1);
        umur=(EditText)findViewById(R.id.textumur);
        alamat=(EditText)findViewById(R.id.textalamat);
        penyakit=(EditText)findViewById(R.id.textkeluhan);
        tampilkan = (TextView) findViewById(R.id.tampilkan);
        daftar=(Button)findViewById(R.id.btn_ambil_antri_operator1);
        status=(TextView)findViewById(R.id.status_operator1);
        getJumlahData();
       
        daftar.setOnClickListener(new View.OnClickListener() {
       
         @Override
         public void onClick(View v) {
           
            // TODO Auto-generated method stub
       
        //atur variabel utk menampung pilihan jenis kelamin dalam bentk radio button
        String type = "";
        switch (jk.getCheckedRadioButtonId()) {
        case R.id.pria_operator1:
        type="1";
        break;
        case R.id.perempuan_operator1:
        type="2";
        break;
        }
             
           
            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("nama", nama.getText().toString()));
            postParameters.add(new BasicNameValuePair("jenkel", type));
            postParameters.add(new BasicNameValuePair("umur", umur.getText().toString()));
            postParameters.add(new BasicNameValuePair("alamat", alamat.getText().toString()));
            postParameters.add(new BasicNameValuePair("penyakit", penyakit.getText().toString()));
           
/*            String valid = "1";*/     
           
            String response = null;
           
            try {
             
               response = CustomHttpClient.executeHttpPost(CustomHttpClient.URL+"ambil_no_operator1.php", postParameters);
             
               String res = response.toString();
             
               res = res.trim();
             
               res = res.replaceAll("\\s+","");
status.setText(res);
             
               if (res.equals("1")){
               status.setText("Registrasi Operator Perawatan Wajah !!");
               }
               else{
               status.setText("Registrasi Untuk Melakukan Perawatan Wajah Berhasil !! Silahkan Cek Historis");
               getJumlahData();
               }
             
            }
           
            catch (Exception e) {
             
               nama.setText(e.toString());
             
            }
             
         }
           
           
      });
    }
   
    private void getJumlahData(){
    try {
String count = CustomHttpClient.executeHttpGet(CustomHttpClient.URL+"get_data1.php");
JSONObject dataObject = new JSONObject(count);
JSONArray dataArray = new JSONArray(dataObject.getString("data"));
tampilkan.setText("Jumlah Pendaftar saat ini :  "+ dataArray.length());
} catch (Exception e) {
Log.e("Count Error", e.getMessage());
}
    }
 
    public void btn_ambil_antri_operator1_Clicked(View v) {
Intent panggil_class = new Intent(this, list_dokter.class);
startActivity(panggil_class);

    }
   
    public void btn_kembali_antri_operator1_Clicked(View v) {
Intent panggil_class = new Intent(this, HistoriFragmentActivity.class);
startActivity(panggil_class);

    }
}


2. Buat xmlnya

<?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"
  android:fillViewport="true">
  <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#fff">
 
        <!--  Header  Starts-->
        <LinearLayout android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@layout/header_gradient"
                android:paddingTop="5dip"
                android:paddingBottom="5dip">
                <!-- Logo Start-->
                <ImageView android:src="@drawable/user"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dip"/>
                <!-- Logo Ends -->
        </LinearLayout>
        <!--  Header Ends -->
        <!-- Footer Start -->
        <LinearLayout 
                android:layout_width="fill_parent"
                android:layout_height="90dip"
                android:background="@layout/footer_repeat"
                android:layout_alignParentBottom="true">
        </LinearLayout>
        <!-- Footer Ends -->
 
        <!-- Registration Form -->
        <LinearLayout
          
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          android:layout_below="@id/header">
                
            <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="1dip"
                android:src="@drawable/user"
                android:text="[Perawatan Wajah]  "
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#0f4b49"/>
            
            
             
             <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="1dip"
                android:src="@drawable/user"
                android:text="Open : Setiap Hari"
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#0f4b49"/>
             
             <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="0dip"
                android:layout_marginBottom="1dip"
                android:src="@drawable/user"
                android:text="Waktu Buka : 09:00 WITA - 22:00 WITA"
                android:gravity="center"
                android:textSize="17dip"
                android:textColor="#0f4b49"/>
             
             <TextView 
                 android:id="@+id/tampilkan"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="20dip"
                android:src="@drawable/user"
                android:text="Jumlah Pelanggan di ruang spes wajah saat ini :  "
                android:gravity="center"
                android:textSize="16dip"
                android:textColor="#0f4b49"/>
             <TextView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:layout_marginBottom="40dip"
                android:text="Isikan identitas Diri Anda dengan benar"
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#0f4b49"/>
          <!-- Full Name Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Nama Lengkap"/>
          <EditText android:id="@+id/txtnamapasien1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          <RadioGroup
android:id="@+id/jekel_operator1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
          <RadioButton
android:id="@+id/pria_operator1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pria" />

<RadioButton
android:id="@+id/perempuan_operator1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perempuan" />
</RadioGroup>
          <!--  Username Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Umur"/>
          <EditText android:id="@+id/textumur"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Alamat"/>
          <EditText android:id="@+id/textalamat"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Jenis Perawatan Wajah"/>
          <EditText android:id="@+id/textkeluhan"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          <TextView
android:id="@+id/status_operator1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
          
          
          <!-- Register  -->
          <Button
        android:id="@+id/btn_ambil_antri_operator1"
        style="@style/btnStyleSeagull"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="21dp"
        android:onClick="btn_ambil_antri_operator1_Clicked"
        android:text="DAFTAR"
        android:textColor="#fff" />
        
        <Button
        android:id="@+id/btn_kembali_antri_operator1"
        style="@style/btnStyleSeagull"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="21dp"
        android:onClick="btn_kembali_antri_operator1_Clicked"
        android:text="CEK HISTORY"
        android:textColor="#fff" />  
          
          <!-- Link to Login Screen -->
           
 
        </LinearLayout>
        <!-- Registration Form Ends -->
  </RelativeLayout>
 </ScrollView>

 
 

Tutorial Membuat Tampilan Registrasi Untuk Praktikum Lanjutan Anata Salon Basis Android

Dibawah ini langkah-langkahnya :

1. Buat class pendaftaran_user.java

2. Scriptn pendaftaran_user.java

package thefly.org;

import go_antri.org.R;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;




public class pendaftaran_user extends Activity {
    public DatePickerDialog myDialog;
 
    EditText nama,ttl,alamat,email,pekerjaan,username,password;
    RadioGroup jk;
    TextView status;
    Button daftar;;
     
    /** Called when the activity is first created. */
    @Override
     
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pendaftaran_user);
       
       
       
       
        nama=(EditText)findViewById(R.id.txtnama);
        jk=(RadioGroup) findViewById(R.id.jekel);
        alamat=(EditText)findViewById(R.id.txtalamat);
        email=(EditText)findViewById(R.id.txtemail);
        pekerjaan=(EditText)findViewById(R.id.txtpekerjaan);
        username=(EditText)findViewById(R.id.textusername2);
        password=(EditText)findViewById(R.id.textpassword2);
       
       
        daftar=(Button)findViewById(R.id.btn_daftar);
        status=(TextView)findViewById(R.id.txtstatus2);
        daftar.setOnClickListener(new View.OnClickListener() {
       
         @Override
       
         public void onClick(View v) {
           
            // TODO Auto-generated method stub
           
            //atur variabel utk menampung pilihan jenis kelamin dalam bentk radio button
             String type=null;
             switch (jk.getCheckedRadioButtonId()) {
             case R.id.pria:
             type="1";
             break;
             case R.id.perempuan:
             type="2";
             break;
             }
                   
           
            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("nama", nama.getText().toString()));
            postParameters.add(new BasicNameValuePair("ttl", type));
            postParameters.add(new BasicNameValuePair("jk", type));
            postParameters.add(new BasicNameValuePair("alamat", alamat.getText().toString()));
            postParameters.add(new BasicNameValuePair("email", email.getText().toString()));
            postParameters.add(new BasicNameValuePair("pekerjaan", pekerjaan.getText().toString()));
            postParameters.add(new BasicNameValuePair("username", username.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", password.getText().toString()));
           
/*            String valid = "1";*/     
           
            String response = null;
           
            try {
             
                 response = CustomHttpClient.executeHttpPost(CustomHttpClient.URL+"pendaftaran_user.php", postParameters);
             
               String res = response.toString();
             
               res = res.trim();
             
               res = res.replaceAll("\\s+","");
status.setText(res);
             
               if (res.equals("1")) status.setText("Registrasi Gagal !!");
             
               else status.setText("Registrasi Berhasil !! Silahkan Login");
             
            }
           
            catch (Exception e) {
             
               nama.setText(e.toString());
             
            }
             
         }
           
           
      });
    }
 
    public void btn_daftar_Clicked(View v) {
        Intent panggil_class = new Intent(this, Login.class);
        startActivity(panggil_class);
    }
   public void btn_login_ulang_Clicked(View v) {
        Intent panggil_class = new Intent(this, Login.class);
        startActivity(panggil_class);
    }
}


3. Buat tampilannya

<?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"
  android:fillViewport="true">
  <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#fff">
 
        <!--  Header  Starts-->
        <LinearLayout android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@layout/header_gradient"
                android:paddingTop="5dip"
                android:paddingBottom="5dip">
                <!-- Logo Start-->
                <ImageView android:src="@drawable/user"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dip"/>
                <!-- Logo Ends -->
        </LinearLayout>
        <!--  Header Ends -->
        <!-- Footer Start -->
        <LinearLayout 
                android:layout_width="fill_parent"
                android:layout_height="90dip"
                android:background="@layout/footer_repeat"
                android:layout_alignParentBottom="true">
        </LinearLayout>
        <!-- Footer Ends -->
 
        <!-- Registration Form -->
        <LinearLayout
          
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          android:layout_below="@id/header">
          <!-- Full Name Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Nama Lengkap"/>
          <EditText 
              android:id="@+id/txtnama"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Tanggal-Bulan-Tahun Lahir"/>
           <EditText 
              android:id="@+id/txtttl"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          
          <RadioGroup
android:id="@+id/jekel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
          <RadioButton
android:id="@+id/pria"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pria" />

<RadioButton
android:id="@+id/perempuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perempuan" />
</RadioGroup>
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Alamat"/>
          <EditText android:id="@+id/txtalamat"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Email"/>
          <EditText android:id="@+id/txtemail"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
          
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Pekerjaan"/>
          <EditText android:id="@+id/txtpekerjaan"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          
                    
          <!--  Username Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Username"/>
          <EditText android:id="@+id/textusername2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          <!-- Password Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Password"/>
          <EditText android:id="@+id/textpassword2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:password="true"
                android:singleLine="true"
                android:layout_marginTop="5dip"/>
          
          <TextView
android:id="@+id/txtstatus2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
          <!-- Register Button -->
          <Button
        android:id="@+id/btn_daftar"
        style="@style/btnStyleSeagull"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="81dp"
        android:onClick="btn_daftar_Clicked"
        android:text="DAFTAR"
        android:textColor="#fff" />
          <!-- Link to Login Screen -->
          <Button android:id="@+id/link_login"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="40dip"
                android:layout_marginBottom="40dip"
                android:text="Sudah memiliki Akun! Klik Login disini"
                android:onClick="btn_login_ulang_Clicked"
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#025f7c"/>
 
        </LinearLayout>
        <!-- Registration Form Ends -->
  </RelativeLayout>
 </ScrollView>


Tutorial Membuat Login Untuk Aplikasi Salon Berbasis Android

Demikian langkah-langkahnya :

1. Buat class Login.java

package thefly.org;

import go_antri.org.R;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;




public class Login extends Activity {
EditText username,password;
TextView status;
Button login;





    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
       
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
       
        username=(EditText) findViewById(R.id.txtusername);
        password=(EditText) findViewById(R.id.txtpassword);
        status=(TextView) findViewById (R.id.txtstatus);
       
        login=(Button) findViewById (R.id.btn_login);
       
       
        login.setOnClickListener(new View.OnClickListener() {
           
            @Override
           
            public void onClick(View v) {
             
               // TODO Auto-generated method stub
           
           
               ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
             
               //"user" itu adalah nama fild dari database yang di tuju
             
               postParameters.add(new BasicNameValuePair("username", username.getText().toString()));
                 
               postParameters.add(new BasicNameValuePair("password", password.getText().toString()));
             
             
               String response = null;
             
               try {
                 
                  response = CustomHttpClient.executeHttpPost(CustomHttpClient.URL+"check_login.php", postParameters);
                 
                  String res = response.toString();
                 
                  res = res.trim();
                 
                  res = res.replaceAll("\\s+","");
                 
                  status.setText(res);
                 
                  if (res.equals("1"))
                  {
                   status.setText("Berhasil Login");
                    btn_login_Clicked(v);
                 
                  }
                  else {
                    status.setText("Maaf!! Username dan Password tidak sesuai");
                   
                       }
               }
             
               catch (Exception e) {
                 
                  status.setText(e.toString());
                 
               }
             
           
           
            //btn_login_Clicked(v);
             
            }
           
            });
     
   
    } 
 // melakukan pendaftaran user
       
    public void btn_daftar_Clicked(View v) {
Intent panggil_class = new Intent(this, pendaftaran_user.class);
startActivity(panggil_class);
}
   
 
// apabila user berhasil login.
   
    public void btn_login_Clicked(View v) {
Intent panggil_class = new Intent(this, list_dokter.class);
startActivity(panggil_class);
}

   
    public void keluar(){
AlertDialog.Builder pesan= new AlertDialog.Builder(this);
pesan.setMessage("Anda Yakin Ingin Menutup Aplikasi SISTEM ANATA SALON N SKINCARE?")
.setCancelable(false)
.setPositiveButton("Ya", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();

}
})
.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
}).show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_BACK){
keluar();
}
return super.onKeyDown(keyCode, event);
}
}


3. Buat login.xml di folder layout untuk tampilan.

<?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"
  android:fillViewport="true">
  <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#ec5f98">
  <ImageView
    android:id="@+id/imageView1"
    android:scrollbars="vertical" 
    android:fadingEdge="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:adjustViewBounds="true" 
    />
        <!--  Header Starts-->
        <LinearLayout android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@layout/header_gradient"
    android:paddingTop="5dip"
    android:paddingBottom="5dip">
        <!-- Logo Start-->
        <ImageView android:src="@drawable/user"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"/>
        <!-- Logo Ends -->
</LinearLayout>

        <!--  Header Ends -->
 
        <!-- Footer Start -->
        
        <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="90dip"
    android:background="@layout/footer_repeat"
    android:layout_alignParentBottom="true">
</LinearLayout>

        <!-- Footer Ends -->
 
        <!-- Login Form -->
        
        <LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          android:layout_below="@id/header">
        
          <!--  Email Label -->

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/l" />

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="31dp"
        android:id="@+id/tableLayout">

        <TableRow android:padding="10dp"
            android:background="#eae47e">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Username : "
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textStyle="bold" />
            <EditText
                android:id="@+id/txtusername"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:layout_marginLeft="10dp"
                android:layout_weight="1"
                android:inputType="none" />
        </TableRow>

        <TableRow android:layout_marginTop="10dp"
            android:padding="10dp"
            android:background="#eae47e">


            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Password               :"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/txtpassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:ems="10"
                android:padding="5dp"
                android:layout_marginLeft="10dp"
                android:layout_weight="1" />

        </TableRow>
    </TableLayout>
    
    

    <TextView
        android:id="@+id/txtstatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#b00808"
        android:text=""
        android:textStyle="bold"
        android:textSize="15sp"
        android:layout_marginBottom="10dp" />

    <Button
        android:id="@+id/btn_login"
        style="@style/btnStyleSeagull"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView3"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/textView3"
        android:layout_marginTop="22dp"
        android:background="#e01080"
        android:onClick="btn_login_Clicked"
        android:text="LOGIN"
        android:textColor="#ffffff"
        android:textStyle="bold" />

    <Button
        android:id="@+id/link_daftar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_login"
        android:layout_below="@+id/btn_login"
        android:layout_marginTop="18dp"
        android:onClick="btn_daftar_Clicked"
        android:text="Belum punya akun? Register disini" 
        android:textColor="#000000"/>
 
</LinearLayout>
        <!-- Login Form Ends -->
 
  </RelativeLayout>
</ScrollView>


Cara Membuat List Perawatan untuk Aplikasi Anata Shalon & Skincare berbasis Android - Praktikum Lanjutan

Demikian langkah-langkahnya :

1. Buat class List_Perawatan.java di package anata.org

2. Script

package thefly.org;

import thefly.org.histori.HistoriFragmentActivity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class list_dokter extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

String[] listdokter = new String[]{
"1. Perawatan Wajah \n [Spes Wajah]",
"2. Perawatan Tubuh \n [Spes Tubuh & Medypedy]",
"3. Perawatan Rambut \n [Spes Rambut]",
"4. Aerobik, Dance, Zumba, Yoga \n [n]",
"5. Produk Anata \n [Ruang Jual Produk]",
"Lihat Histori",
"Keluar", };

this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, listdokter));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
// Menangkap nilai text yang dklik
Object o = this.getListAdapter().getItem(position);
String pilihan = o.toString();
// Menampilkan hasil pilihan menu dalam bentuk Toast
tampilkanPilihan(pilihan);

}

protected void tampilkanPilihan(String pilihan) {
try {
// Intent digunakan untuk sebagai pengenal suatu activity
Intent i = null;
if (pilihan.equals("1. Perawatan Wajah \n [Spes Wajah]")) {
i = new Intent(this, pendaftaran_operator1.class);
} else if (pilihan.equals("2. Perawatan Tubuh \n [Spes Tubuh & Medypedy]")) {
i = new Intent(this, pendaftaran_operator2.class);
} else if (pilihan.equals("3. Perawatan Rambut \n [Spes Tata Rambut]")) {
i = new Intent(this, pendaftaran_operator3.class);
} else if (pilihan.equals("4. Yoga, Zumba, Aerobik \n [Spes Dance]")) {
i = new Intent(this, pendaftaran_operator4.class);
} else if (pilihan.equals("5. Produk Anata [Jual Produk]")) {
i = new Intent(this, pendaftaran_operator5.class);
} else if (pilihan.equals("Lihat Histori")) {
//Panggil activity history dlm bentuk fragment
i = new Intent(this, HistoriFragmentActivity.class);

} else if (pilihan.equals("Keluar")) {
// Intent exit = new Intent(Intent.ACTION_MAIN);
// startActivity(exit);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Anda Yakin Ingin Menutup Aplikasi ANATA SALON?")
.setCancelable(false).setPositiveButton("Ya",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
Intent exit = new Intent(
Intent.ACTION_MAIN);
exit.addCategory(Intent.CATEGORY_HOME);
exit
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(exit);
}
}).setNegativeButton("Tidak",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
}).show();

} else {
Toast.makeText(
this,
"Anda Memilih: " + pilihan
+ " , Actionnya belum dibuat",
Toast.LENGTH_LONG).show();
}
startActivity(i);
} catch (Exception e) {
e.printStackTrace();
}
}
}


3. Buat main.xml di layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 android:orientation="vertical">

 <TextView android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:padding="10dp" />

 <ListView android:id="@+id/listView1" android:layout_width="fill_parent"
  android:layout_height="fill_parent" />

</LinearLayout>


Membuat Loading untuk Aplikasi Anata Shalon & Skincare berbasis Android

Pada kali ini saya akan membahas tentang membuat Loading untuk aplikasi Anata Shalon & Skincare. Demikian cara-caranya :

1. Buatlah kelas loading.java di package ini.


2. Script loading.java

package thefly.org;

import go_antri.org.PerawatanWajah;
import go_antri.org.R;
import go_antri.org.SelamatDatang;
import go_antri.org.Welcome;
import android.app.Activity;

import android.view.View;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.content.Intent;
import android.content.pm.ActivityInfo;


public class loading extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
     // METHOD 1   
       
        /****** Create Thread that will sleep for 5 seconds *************/       
       Thread background = new Thread() {
           public void run() {
               
               try {
                   // Thread will sleep for 5 seconds
                   sleep(5*1000);
                   
                   // After 5 seconds redirect to another intent
                   Intent i=new Intent(getBaseContext(),SelamatDatang.class);
                   startActivity(i);
                   
                   //Remove activity
                   finish();
                   
               } catch (Exception e) {
               
               }
           }
       };
       
       // start thread
       background.start();
       
//METHOD 2 
       
       /*
       new Handler().postDelayed(new Runnable() {
           
           // Using handler with postDelayed called runnable run method

           @Override
           public void run() {
               Intent i = new Intent(MainSplashScreen.this, FirstScreen.class);
               startActivity(i);

               // close this activity
               finish();
           }
       }, 5*1000); // wait for 5 seconds
       */
   }
   
   @Override
   protected void onDestroy() {
       
       super.onDestroy();
       
   }
}

3. Buat loading.xml di folder layout

<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:background="@drawable/g"
    tools:context=".b'smart" >

        <ProgressBar
        android:id="@+id/progressBar2"
         android:gravity="center|center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="false"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        style="?android:attr/progressBarStyleLarge" />
   

</RelativeLayout>


HTTP Client untuk Aplikasi Android Natasha Saloon & Skincare

Pada kesempatan kali ini saya akan menjelaskan langkah-langkah membuat HTTP Client untuk aplikasi Android Natasha Saloon & Skincare

package thefly.org;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class CustomHttpClient {
//URL public tujuannya ketika ada perubahan alamat IP atau host cukup ganti satu tempat saja
// biar tidak mengidet di semua file yang berkaitan dengan HOST
public static String URL="http://192.168.100.7/antrian/klien_android/";
   /** The time it takes for our client to timeout */
    public static final int HTTP_TIMEOUT = 30 * 1000; // milliseconds

    /** Single instance of our HttpClient */
    private static HttpClient mHttpClient;

    /**
     * Get our single instance of our HttpClient object.
     *
     * @return an HttpClient object with connection parameters set
     */
    private static HttpClient getHttpClient() {
        if (mHttpClient == null) {
            mHttpClient = new DefaultHttpClient();
            final HttpParams params = mHttpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
            HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
            ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
        }
        return mHttpClient;
    }

    /**
     * Performs an HTTP Post request to the specified url with the
     * specified parameters.
     *
     * @param url The web address to post the request to
     * @param postParameters The parameters to send via the request
     * @return The result of the request
     * @throws Exception
     */
    public static String executeHttpPost(String url, ArrayList<NameValuePair> postParameters) throws Exception {
        BufferedReader in = null;
        try {
            HttpClient client = getHttpClient();
            HttpPost request = new HttpPost(url);
            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
            request.setEntity(formEntity);
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();

            String result = sb.toString();
            return result;
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * Performs an HTTP GET request to the specified url.
     *
     * @param url The web address to post the request to
     * @return The result of the request
     * @throws Exception
     */
    public static String executeHttpGet(String url) throws Exception {
        BufferedReader in = null;
        try {
            HttpClient client = getHttpClient();
            HttpGet request = new HttpGet();
            request.setURI(new URI(url));
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();

            String result = sb.toString();
            return result;
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}