Geo*_*dra 3 android parse-platform progress-bar
即时通讯创建一个应用程序登录到parse.com,然后浏览项目和其他功能,但我无法添加进度条或任何类似的东西,所以当应用程序登录时没有发生任何事情我只是等待它登录和移动到其他活动
这是我在任何帮助中登录的代码
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.Toast;
import com.androidbegin.parselogintutorial.R;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseUser;
public class LoginActivity extends Activity {
// Declare Variables
Button loginbutton;
String usernametxt;
String passwordtxt;
EditText password;
EditText username;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from login.xml
setContentView(R.layout.login);
// Locate EditTexts in login.xml
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
// Locate Buttons in main.xml
loginbutton = (Button) findViewById(R.id.login);
// Login Button Click Listener
loginbutton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
// Send data to Parse.com for verification
ParseUser.logInInBackground(usernametxt, passwordtxt,
new LogInCallback() {
public void done(ParseUser user, ParseException e) {
// If user exist and authenticated, send user to Welcome.class
if(user !=null){
Intent intent = new Intent(
LoginActivity.this,
AddUserPage.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Successfully Logged in",
Toast.LENGTH_LONG).show();
finish();
}else{
Toast.makeText(getApplicationContext(), "No such user", Toast.LENGTH_LONG).show();
username.setText("");
password.setText("");
}}
});
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
`
将进度条定义为 private ProgressDialog mProgress;
在oncreate使用这个
mProgress = new ProgressDialog(context);
mProgress.setTitle("Processing...");
mProgress.setMessage("Please wait...");
mProgress.setCancelable(false);
mProgress.setIndeterminate(true);
Run Code Online (Sandbox Code Playgroud)
现在这个
// Login Button Click Listener
loginbutton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
mProgress.show();
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();
// Send data to Parse.com for verification
ParseUser.logInInBackground(usernametxt, passwordtxt,
new LogInCallback() {
public void done(ParseUser user, ParseException e) {
// If user exist and authenticated, send user to Welcome.class
if(user !=null){
mProgress.dismiss();
Intent intent = new Intent(
LoginActivity.this,
AddUserPage.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Successfully Logged in",
Toast.LENGTH_LONG).show();
finish();
}else{
mProgress.dismiss();
Toast.makeText(getApplicationContext(), "No such user", Toast.LENGTH_LONG).show();
username.setText("");
password.setText("");
}}
});
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10347 次 |
| 最近记录: |