I know there are few questions regard this issue but all of them are using animation. I have no animation at all in my activity. I have a TextView that by default is visible and is set to Gone based on a Feature-Flag that I get in my Splash screen.
This is my xml file:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/profile_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/profile_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="?android:actionBarSize">
<TextView
android:id="@+id/payments_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:background="@drawable/profile_payment_bg"
android:clickable="true"
android:drawableLeft="@drawable/ic_profile_payment"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:onClick="onClick"
android:padding="8dp"
android:text="Payment"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@android:color/white" />
...
</LinearLayout>
</FrameLayout>
Although I'm setting Clickable and OnClickListener functionality to false and null respectively, OnClick() functionality is called even when my Payment button is not visible :(
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_profile);
this.mPayments = (TextView) findViewById(R.id.payments_btn);
// Check if payment functionality available for the Passenger
final PassengerFeatureResponse cachedFeature = FeatureResponse.fromJsonString(PreferenceUtils.getFeatureResponse(this));
if (cachedFeature == null || !cachedFeature.isMade())
{
this.mPayments.setVisibility(View.GONE);
this.mPayments.setClickable(false);
this.mPayments.setOnClickListener(null);
}
}
I even tried to set visibility to Gone from xml file and set it to visible from code however the functionality was same :(
It's probably because I have defined onClick
functionality from xml file and my problem would be fixed if I set click listener from code, however, I'm looking for fix the issue in this way.
Any suggestion would be appreciated. Thanks.
Try this on
FrameLayout
like this