我正在開發Android應用程序,並且在更新GUI時遇到問題。基本上我想實現的是當我的用戶點擊Sign In按鈕時,按照下面的定義調用groupLogInProgress上的setVisibility方法,並將其設置爲View.VISIBILE。然後啓動我的方法,記錄他們,如果它返回一個成功值,將groupLogInProgress設置爲View.GONE,並將groupLogInSuccess設置爲View.VISIBLE(顯示「登錄成功!」)暫停幾秒鐘,然後開始我的主要意圖。如果我的登錄方法返回false,請將groupLogInProgress設置爲View.GONE,將groupLogInError設置爲View.VISIBLE。我似乎無法弄清楚如何在不等待登錄方法完成的情況下導致我的應用程序掛起時發生這些事情。在登錄用戶時顯示進度文本 - Android App
下面是我到目前爲止,任何幫助非常感謝!
//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 2013-05-02 17:05:28
看看http:// developer .android.com/reference/android/os/AsyncTask.html,這可能對你有所幫助。 – Wamasa 2013-05-02 17:06:59