Hello all.

public class LoginFragmentActivity extends SherlockFragment {
    EditText e1 = null;
    EditText e2 = null;
    Button b;
    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() {
            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(
                    builder.setMessage("Please fill in all fields");
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,
                                        int which) {
                    AlertDialog alert = builder.create();
                } else {
                    Toast.makeText(getActivity(), "Welcome",
                    Intent intent = new Intent(getActivity(), Home.class);
        return view;

I wrote something before posting the written code snippet above but to my surprise,it got cleaned up.The text editor been used here highlights everything on mouse movement.
The issue behind the code is this,i'm building an android app which has 2 EditTexts (like Textfields in java) one takes an email address inputted by the user and the other, password.
i assigned the input gotten from the user to 2 different strings for validation (check out lines 15 to the end of the code).If the user doesnt input a tin,it should display a dialog asking
him/her to inout something on click of th button.But anytime i run this,the app crashes with a Exception saying "NullPointerException at Line 15". Please can somebody help me with this,
by pointing out where i went wrong in this,i have tried evrything.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.