btnok=(Button)findViewById(R.id.btnok); btnok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("username", un.getText().toString())); postParameters.add(new BasicNameValuePair("password", pw.getText().toString())); //String valid = "1"; String response = null; try{ response = CustomHttpClient.executeHttpPost("http://192.168.1.2/android/check.php", postParameters); String res=response.toString(); // res = res.trim(); res= res.replaceAll("\\s+",""); //error.setText(res); if(res.equals("1")) error.setText("Correct Username or Password"); else error.setText("Sorry!! Incorrect Username or Password"); } catch (Exception e) { un.setText(e.toString()); }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:text="Two Button AlertDialog" android:id="@+id/btnTwoButton" android:layout_width="200dip" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> </LinearLayout>
package com.androidjump.app.simpledialog; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ private Button btnOneButton, btnTwoButton, btnList, btnRadio; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //link ไปที่ปุ่มหน้า Main.xml ที่สร้างไว้ btnTwoButton = (Button)findViewById(R.id.btnTwoButton); btnTwoButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub getTwoButtonAlertDialog(); } } ); } // ใส่ event getTwoButtonAlert public void getTwoButtonAlertDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Hello, I am two buttons dialog.") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง