Ich habe ein Grundlayout, das einige Ansichten enthält. Wenn eine Netzwerkverbindung besteht, wird ein RecyclerView angezeigt. Wenn der Benutzer zum Aktualisieren streift und keine Verbindung besteht, werden eine Schaltfläche und eine Textansicht sichtbar, die innerhalb des Basislayouts an erster Stelle unsichtbar sind. Das Problem ist, dass die Schaltfläche in Geräten mit Android-Version < Lollilop nicht anklickbar ist.Button ist in Versionen nicht anklickbar <Lollipop
basic_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listSurveysRlt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.rey.material.widget.TextView
android:id="@+id/codeDescTtv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/code_dest_txv_padding_bottom"
android:visibility="gone"
android:gravity="center"
android:layout_above="@+id/sRetryBtn"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textSize="@dimen/code_dest_txv_text_size"
android:textColor="@android:color/black"
android:textStyle="bold" />
<com.rey.material.widget.Button
android:id="@+id/sRetryBtn"
android:layout_width="@dimen/action_btn_width"
android:layout_height="@dimen/action_btn_height"
android:text="@string/retry"
android:textColor="@android:color/white"
android:background="@drawable/ripple_drawable"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLlt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/completedSurveysRcV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/surveys_rcv_margin_top" />
</android.support.v4.widget.SwipeRefreshLayout>
<ImageView
android:id="@+id/noSurveysImv"
android:layout_width="@dimen/no_surveys_imv_width"
android:layout_height="@dimen/no_surveys_imv_height"
android:src="@drawable/no_surveys"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/no_surveys_imv_margin_top"
android:visibility="gone"
android:contentDescription="@string/ongoing" />
<com.rey.material.widget.TextView
android:id="@+id/noSurveysTxv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/noSurveysImv"
android:text="@string/no_completed"
android:textSize="@dimen/no_surveys_txv_text_size"
android:textColor="@color/no_surveys_txv_color"
android:visibility="gone"
android:layout_centerHorizontal="true" />
</RelativeLayout>
das Verfahren, das die corrensponding Ansichten von sichtbar in unsichtbar und umgekehrt verwandelt: hinter diesem seltsamen Verhalten der ich den Grund herausgefunden
private void onErrorBackgroundView(int code) {
listSurveysRlt.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.view_color));
completedSurveysRcV.setVisibility(View.GONE); //RecyclerView
codeDescTtv.setVisibility(View.VISIBLE); //TextView
retryBtn.setVisibility(View.VISIBLE); //not clickable button
codeDescTtv.setText(getResources().getString(inputValidationCodes.get(code)));
}
Haben Sie versucht, auch 'retryBtn.setEnabled (true);'? – Salem
Wo ist der Code zum Hinzufügen Klick Listener auf der Schaltfläche? – dweebo