Android 앱에서 작업 중이며 GUI를 업데이트하는 데 문제가 있습니다. 기본적으로 내가 원하는 것은 사용자가 로그인 단추를 클릭하고 아래 정의 된대로 groupLogInProgress에서 setVisibility 메서드를 호출하고 View.VISIBILE로 설정할 때입니다. 그런 다음 로그를 기록한 내 메서드를 실행하고 성공 값을 반환하면 groupLogInProgress를 View.GONE으로 설정하고 groupLogInSuccess를 View.VISIBLE로 설정합니다 ("로그인 성공"표시). 잠시 멈추고 내 주요 의도. 내 로그인 메소드가 false를 반환하면 groupLogInProgress를 View.GONE으로 설정하고 groupLogInError를 View.VISIBLE로 설정하십시오. 로그 인 메서드가 완료 될 때까지 기다리는 동안 내 앱이 멈추지 않으면 서 이러한 일이 발생하도록하는 방법을 알아낼 수 없습니다.사용자 로그인 중 진행 상태 표시 - Android App
아래는 제가 지금까지 가지고있는 것입니다, 어떤 도움이 대단히 감사합니다 !!
private class LoginTask extends AsyncTask<Void, Integer, Integer>
{
static final int STATUS_SUCCESS = 1;
static final int STATUS_FAIL = 0;
@Override
protected void onPreExecute()
{
hideAllStatus(); //this is simple method that sets all above groups to View.GONE
}
@Override
protected Integer doInBackground(Void... params)
{
loginData = LogInUser(username, password);
return (loginData == null ? STATUS_FAIL : STATUS_SUCCESS);
}
@Override
protected void onPostExecute(Integer result)
{
if (result == STATUS_FAIL)
{
//set groupLogInError to View.VISIBLE, all others to GONE
}
else
{
//set groupLogInSuccess to View.VISIBLE, all others to GONE and pause for a few seconds to allow user to see "Sign In Successful!" message
}
}
}
가 실행 작업 :
//Hide all Sign In progress/success/error layouts onCreate
groupLogInProgress = (LinearLayout) findViewById(R.id.groupLoginProgress);
groupLogInSuccess = (LinearLayout) findViewById(R.id.groupLoginSuccess);
groupLogInError = (LinearLayout) findViewById(R.id.groupLoginError);
hideAllStatus(); //this is simple method that sets all above groups to View.GONE
//Sign in button onClick handler
public void onClick(View v) {
loginData = LogInUser(username, password);
if(loginData == null)
{
//set groupLogInError to View.VISIBLE, all others to GONE
}
else
{
//set groupLogInSuccess to View.VISIBLE, all others to GONE and pause for a few seconds to allow user to see "Sign In Successful!" message
}
}
AsyncTask, http://developer.android.com/guide/components/processes-and-threads.html – CSmith
http : // developer를보세요. .android.com/reference/android/os/AsyncTask.html, 이것이 도움이 될 수 있습니다. – Wamasa