What I'm trying to here is to hide the FAB and the text whenever results returns an empty value/string. Methods hideTextView() and setText() are working fine but the FAB are still always being shown whether it returns an empty string or not.
if (args.getString("results").isEmpty()) {
activity.hideTextView(text);
activity.hideButton(fabButton);
} else {
activity.setText(text, args.getString("text"));
activity.showButton(fabButton);
Below are the methods I used for showing/hiding the TextViews and the FAB. I've also tried floatingActionButton.hide()
and floatingActionButton.show()
but it's still not working
public void hideButton(final FloatingActionButton floatingActionButton) {
runOnUiThread(new Runnable() {
@Override
public void run() {
floatingActionButton.setVisibility(View.GONE);
//floatingActionButton.hide()
}
});
}
public void showButton(final FloatingActionButton floatingActionButton) {
runOnUiThread(new Runnable() {
@Override
public void run() {
floatingActionButton.setVisibility(View.VISIBLE);
//floatingActionButton.show();
}
});
}
public void hideTextView(final TextView textView) {
runOnUiThread(new Runnable() {
@Override
public void run() {
textView.setVisibility(View.GONE);
}
});
}
public void setText(final TextView text, final String value) {
runOnUiThread(new Runnable() {
@Override
public void run() {
text.setText(value);
}
});
}
fab
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fabButton"
android:layout_alignParentEnd="true"
android:layout_below="@+id/cover"
android:src="@drawable/ic_icon1"
app:backgroundTint="@color/colorAccent"
android:clickable="true"
android:layout_marginRight="210dp"
android:layout_marginTop="-28dp"
android:adjustViewBounds="false"/>