导航抽屉得到意图

时间:2016-12-11 13:35:42

标签: android android-intent android-navigation-drawer

这是我的活动登录代码

public void onClick(View v) {
    switch (v.getId()){
        case  R.id.email_sign_in_button:

            EditText em = (EditText) findViewById(R.id.email);
            EditText pass = (EditText) findViewById(R.id.password);
            String password=pass.getText().toString();
            String email=em.getText().toString();
            String storedPassword =helper.getSinlgeEntry(email,password);
            String storedName =helper.getName(email);
            if(password.equals(storedPassword))
            {
                Intent i1 = new Intent(LoginActivity.this, MainActivity.class);
                i1.putExtra("1", storedName);
                i1.putExtra("2",email);
                startActivity(i1);
                Toast.makeText(LoginActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show();

            }
            else
            {
                Toast Tpass = Toast.makeText(LoginActivity.this, "Invalide Mot de Passe", Toast.LENGTH_LONG);
                Tpass.show();
            }

            break;
            case  R.id.creer:
            Intent i1 = new Intent(LoginActivity.this, InscriptioNActivity.class);
            startActivity(i1);
            break;
    }
}

代码中的意图将通过两个值电子邮件和名称

发送给MaintActivity

enter image description here

我想放在那里,这是导航标题

enter image description here

就像这个例子一样

enter image description here 我想要放在哪里 在MainActivty

getIntent().getExtras().getInt("1");

如果代码中缺少的东西我会添加 非常感谢你^^

0 个答案:

没有答案