如何从解析到android检索数据?

时间:2015-04-05 15:07:13

标签: android

请帮助我!如何在用户登录后从解析中检索数据并将其带到另一个活动并将其放入TextView中?这是我用户登录的第一个活动。

protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Parse.initialize(this, "SMXvtOppMAR1x2NsGb0eJ4vr8qKCOLKKDilnv4",
            "Ro7d1xT87p7GvnAIguHEhu7V7CuVPCEqbqY7qs");

    userID = (EditText) findViewById(R.id.editUserId);
    password = (EditText) findViewById(R.id.editPassword);
    txtuser = (TextView) findViewById(R.id.txtUserID);
    txtpassword = (TextView) findViewById(R.id.txtPassword);
    login = (Button) findViewById(R.id.butLogin);

    login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) 
        {
            ID1 = userID.getText().toString();
            ID =Integer.parseInt(ID1);

            query  = ParseQuery.getQuery("SUPERVISOR");
            query.whereEqualTo("Supervisor_ID",ID);
            query.whereEqualTo("Supervisor_Password", password.getText().toString());
            query.getFirstInBackground(new GetCallback<ParseObject>() {

                @Override
                public void done(ParseObject result, ParseException e) 
                {
                    if (result != null) {
                        // Go to the supervisor screen
                        Intent i = new Intent(LoginScreen.this,
                                SupervisorScreen.class);
                        startActivity(i);
                    } else {
                        // invalid user name
                        Toast.makeText(getApplicationContext(),
                                "Invalid user name and password",
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
        }
    });
}

这是另一个应该显示他的名字和实验室编号和部门的活动。

protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.supervisor_screen);
    Parse.initialize(this, "SMXvtOppMAR1x2NsG1zb0eJ4vqKCOLKKDilnv4",
            "Ro7d1xT87p7GvnAIguHEhu7V7CuVPCEqbqY7qs");

    name = (TextView) findViewById(R.id.txtnamesuper);
    lab = (TextView) findViewById(R.id.txtlabnumsup);
    department = (TextView) findViewById(R.id.txtdepartmentsup);
    addinfo = (Button) findViewById(R.id.butAddInfo);
    maintinfo = (Button) findViewById(R.id.butMaintenInfo);
}
}

0 个答案:

没有答案