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>
0 komentar:
Posting Komentar