java - Android ProgressBar in FrameLayout is never visible -
hello i'm trying show circular progress bar when user clicks on log in button, similar screenshot below.
problem progress bar never shown, tough changed it's visibility view.visible in loginactivity.showprogressbar()
with
progressbar.setvisibility(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 ... /** * personal trainer need log in can have access app. */ public class loginactivity extends appcompatactivity { // variable declarations ... // butterknife allows eliminate findviewbyid calls 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 2 colors textview 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 network call loginbutton.setenabled(false); if (network.userisloggedin()) { loginrefresh(); } else { login(); } // else loginbutton.setenabled(true); } // loginbuttonclick() /** * prepares log in request 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
edit - 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>
here,issue
<include android:id="@+id/log_in_form" layout="@layout/log_in"/>
once check it's property.
if possible send code snippet.
Comments
Post a Comment