Click here to Skip to main content
11,584,040 members (46,171 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Android Phone
hi all Smile | :)

I have this exception when I try to lunch log in activity in android

01-12 21:04:28.994: E/AndroidRuntime(1442): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.msagroup.sbhmg/com.msagroup.sbhmg.LogIn}: java.lang.NullPointerException

here is my .XML file:

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

    <EditText
        android:id="@+id/etmail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="41dp"
        android:inputType="textEmailAddress"
        android:text="@string/email" >
 
        <requestFocus />
    </EditText>
 

    <EditText
        android:id="@+id/etpassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/etmail"
        android:layout_marginTop="16dp"
        android:inputType="textPassword" 
        android:text="@string/password"/>
 

    <Button
        android:id="@+id/btnlogin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/etpassword"
        android:layout_marginTop="16dp"
        android:text="@string/login" />
 

    <TextView
        android:id="@+id/tvcomment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:text="@string/empty" />
 
</RelativeLayout>


and .Java file:

package com.msagroup.sbhmg;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
 
public class LogIn extends Activity {
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        
        Button _gotousermain = (Button) findViewById(R.id.btngotoenglishmain);
        EditText _etmail = (EditText) findViewById(R.id.etmail);
        EditText _etpassword = (EditText) findViewById(R.id.etmail);
        final String _email = _etmail.getText().toString();
        final String _pass = _etpassword.getText().toString();
        final TextView _tvcomm = (TextView) findViewById(R.id.tvcomment);
        
        _gotousermain.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(_email == "msay@live.com" && _pass == "123")
				{
					startActivity(new Intent(LogIn.this, ArMain.class));
				}
				else
				{
					if(_email == "msay@live.com" && _pass == "123")
					{
						startActivity(new Intent(LogIn.this, ArMain.class));
					}
					else
					{
						_tvcomm.setText("Invalid Info. !");
					}
				}
			}
		});
	}
}


thank you all Smile | :)
Posted 13-Jan-12 0:21am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I found the problem

it was a stupid one :\

the ID "btngotoenglishmain"

at

Button _gotousermain = (Button) findViewById(R.id.btngotoenglishmain);

is not exists at the xml file

thank you all Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 314
2 virusstorm 268
3 Richard Deeming 220
4 Dave Kreskowiak 200
0 OriginalGriff 1,623
1 Sergey Alexandrovich Kryukov 1,135
2 Abhinav S 701
3 Dave Kreskowiak 627
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 14 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100