Hello all.
public class LoginFragmentActivity extends SherlockFragment {
EditText e1 = null;
EditText e2 = null;
Button b;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInatanceState) {
View view = inflater.inflate(R.layout.login_layout, container, false);
e1 = (EditText) view.findViewById(R.id.reg_email);
e2 = (EditText) view.findViewById(R.id.reg_password);
b = (Button) view.findViewById(R.id.btnLogin);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String email = e1.getText().toString();
String pname = e2.getText().toString();
if ((email.equals("")) || (pname.equals(""))) {
AlertDialog.Builder builder = new AlertDialog.Builder(
getActivity());
builder.setMessage("Please fill in all fields");
builder.setCancelable(false);
builder.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
Toast.makeText(getActivity(), "Welcome",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getActivity(), Home.class);
startActivity(intent);
}
}
});
return view;
}
}