2016-08-08 4 views
0

안녕하십니까. 사용자가 로그인 버튼을 클릭하면 순환 진행 막대가 표시됩니다. 아래 스크린 샷과 유사합니다.FrameLayout의 Android ProgressBar가 표시되지 않습니다.

enter image description here

문제는 내가 그것을

progressBar.setVisibility(View.VISIBLE);LogInActivity.showProgressBar()에 View.VISIBLE에 대한 가시성의 변경도 힘든, 표시되지 않습니다 진행 표시 줄입니다.

activity_log_in.xml

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout style="@style/layout" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      tools:context=".activity.LogInActivity"> 

    <!-- TW Login Form --> 
    <include 
    android:id="@+id/log_in_form" 
    layout="@layout/log_in"/> 

    <!-- Loading Indicator --> 
    <ProgressBar 
    android:id="@+id/progress_bar" 
    style="@style/Widget.AppCompat.ProgressBar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:indeterminate="true"/> 

</FrameLayout> 

styles.xml

<resources> 

    <!-- ... --> 

    <style name="layout"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">match_parent</item> 
    <item name="android:background">@android:color/white</item> 
    </style> 

    <!-- ... --> 

</resources> 

LogInActivity.java

package com.trainerworkout.trainerworkout.activity; 

// import ... 

/** 
* As a personal trainer I need to log in so that I can have access to the app. 
*/ 
public class LogInActivity extends AppCompatActivity { 
    // variable declarations ... 

    // butterknife allows to eliminate findViewById calls by using @Bind on fields. 
    ... 
    @Bind(R.id.progress_bar) 
    ProgressBar progressBar; 
    @Bind(R.id.log_in_form) 
    RelativeLayout logInForm; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    Log.d(TAG, "onCreate()"); 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_log_in); 
    context = this; 
    network = new Network(this); 
    ButterKnife.bind(this); 

    applyFont(); 

    // Sets two colors for the TextView with HTML Formatting 
    //noinspection deprecation 
    not_a_member_text_view.setText(Html.fromHtml(getString(R.string.not_a_member_string))); 

    if (network.userIsLoggedIn()) { 
     logInRefresh(); 
    } else { 
     showForm(); 
    } // else 
    } // onCreate() 

    public void logInRefresh() { 
    showProgressBar(); 
    network.logInRefresh(this); 
    showForm(); 
    } // logInRefresh() 

    // ... 

    public void logInButtonClick(View view) { 
    Log.d(TAG, "logInButtonClick()"); 
    // Prevent multiple clicks during the network call 
    logInButton.setEnabled(false); 
    if (network.userIsLoggedIn()) { 
     logInRefresh(); 
    } else { 
     logIn(); 
    } // else 
    logInButton.setEnabled(true); 
    } // logInButtonClick() 

    /** 
    * Prepares the log in request to the API 
    */ 
    private void logIn() { 
    String email = emailEditText.getText().toString(); 
    String password = passwordEditText.getText().toString(); 

    if (Valid.validFields(this, email, password, emailEditText, passwordEditText)) { 
     showProgressBar(); 
     network.logIn(this, email, password); 
     showForm(); 
    } else { 
     shakeLogInButton(); 
    } // else 
    } // logIn() 

    // ... 

    public void showForm() { 
    progressBar.setVisibility(View.GONE); 
    logInForm.setVisibility(View.VISIBLE); 
    } // showProgressBar() 

    public void showProgressBar() { 
    progressBar.setVisibility(View.VISIBLE); 
    logInForm.setVisibility(View.GONE); 
    } // showProgressBar() 
} // LogInActivity 

편집 - log_in.xml 여기

<?xml version="1.0" encoding="utf-8"?> 
<!-- TW Log In Form --> 
<RelativeLayout 
    style="@style/layout" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".activity.LogInActivity"> 

    <LinearLayout 
    style="@style/layout" 
    android:layout_margin="@dimen/layout_margin_profile" 
    android:gravity="center" 
    android:orientation="vertical"> 

    <!-- ... --> 

    <!-- Email Field --> 
    <EditText 
     android:id="@+id/email_edit_text" 
     style="@style/edit_text" 
     android:layout_height="wrap_content" 
     android:hint="@string/email" 
     android:inputType="textEmailAddress"/> 

    <-- ... --> 


</RelativeLayout> 
+0

progressBar.setMax (150)에 android:translationZ="8dp"를 추가; in showProgressBar() –

답변

1

, 문제

<include 
    android:id="@+id/log_in_form" 
    layout="@layout/log_in"/> 

와 함께 일단은 재산의 확인.

가능한 경우 코드 스 니펫을 보냅니다.

enter image description here

+0
+0

을 제외한 코드 및 모든 코드가 제대로 작동하는지 테스트했습니다. 편집 끝에 코드 단편을 추가했습니다. 한번 봐주세요. – charlesfranciscodev

+0

코드로 검사했지만 여전히 잘 작동하고 있습니다. – ViramP

1

당신의 ProgressBar

+1

이것은 좋은 설명이지만 답변이 아닙니다. – manetsus

관련 문제