Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t打开下一个活动Android Studio_Android - Fatal编程技术网

Can';t打开下一个活动Android Studio

Can';t打开下一个活动Android Studio,android,Android,当我点击登录按钮时,它会显示toast消息用户名和密码不匹配-即使在我创建新帐户时也是如此。当我登录时,它应该显示新的活动,但这不起作用。我如何解决这个问题 MainActivity.java package com.example.demir.carsharing; import android.content.Intent; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import

当我点击登录按钮时,它会显示toast消息用户名和密码不匹配-即使在我创建新帐户时也是如此。当我登录时,它应该显示新的活动,但这不起作用。我如何解决这个问题

MainActivity.java

package com.example.demir.carsharing;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.content.Intent;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


    DatabaseHelper helper = new DatabaseHelper(this);
    private Button v;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onButtonClick(View v){
        if (v.getId()==R.id.bLogin)
        {
            EditText a = (EditText)findViewById(R.id.TFUsername);
            String str = a.getText().toString();

            EditText b = (EditText)findViewById(R.id.TFPassword);
            String pass = b.getText().toString();

            String password = helper.searchPass(str);

            if(pass.equals(password))
            {
                Intent i = new Intent(MainActivity.this, Display.class);
                i.putExtra("uname", str);
                startActivity(i);
            }
            else
            {
                // Display popup message
                Toast temp =Toast.makeText(MainActivity.this, "Username and Password don't match", Toast.LENGTH_SHORT);
                temp.show();

            }

        }
        if (v.getId()==R.id.bSignUpHere)
        {
            Intent i = new Intent(MainActivity.this, signup.class);
            startActivity(i);
        }

    }
}
Signup.java

package com.example.demir.carsharing;

import android.app.Activity;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by Demir on 19.12.2016..
 */

public class signup extends Activity {

    DatabaseHelper helper = new DatabaseHelper(this);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup);

    }

    public void onSignUpClick(View v)
    {
        if(v.getId() == R.id.bSignUpHere)
        {
            EditText name = (EditText)findViewById(R.id.TFName);
            EditText email = (EditText)findViewById(R.id.TFEmail);
            EditText uname = (EditText)findViewById(R.id.TFuname);
            EditText pass1 = (EditText)findViewById(R.id.TFpass1);
            EditText pass2 = (EditText)findViewById(R.id.TFpass2);

            String namestr  = name.getText().toString();
            String emailstr  = email.getText().toString();
            String unamestr  = uname.getText().toString();
            String passstr1  = pass1.getText().toString();
            String passstr2  = pass2.getText().toString();


            if(!passstr1.equals(passstr2))
            {
                 // DIsplay popup message
                Toast pass =Toast.makeText(signup.this, "Password don't match", Toast.LENGTH_SHORT);
                pass.show();
            }
            else {

                //insert the detaild in database
                Contact c = new Contact();
                c.setName(namestr);
                c.setEmail(emailstr);
                c.setUname(unamestr);
                c.setPass(passstr1);

                helper.insertContact(c);
            }




        }
    }
}
Display.java

package com.example.demir.carsharing;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


/**
 * Created by Demir on 19.12.2016..
 */

public class Display extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.display);
        String username = getIntent().getStringExtra("Username");
        TextView tv = (TextView)findViewById(R.id.TVUsername);
        tv.setText(username);
    }


}
//String username = getIntent().getStringExtra("Username");
    String username = getIntent().getStringExtra("uname");
在Display.java中

package com.example.demir.carsharing;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


/**
 * Created by Demir on 19.12.2016..
 */

public class Display extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.display);
        String username = getIntent().getStringExtra("Username");
        TextView tv = (TextView)findViewById(R.id.TVUsername);
        tv.setText(username);
    }


}
//String username = getIntent().getStringExtra("Username");
    String username = getIntent().getStringExtra("uname");

下一次,在发布问题之前尝试搜索它。看看我所做的一切,但即使在创建新用户时,也会显示用户名和密码不匹配的消息。您是否在Logcat中遇到错误?您的活动都是在AndroidManifest.xml中定义的吗?