Click here to Skip to main content
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 1:21am
(unknown member)

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)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 14 Jan 2012
Copyright © CodeProject, 1999-2014
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