Ich habe ein cardview und eine Schaltfläche in meiner content_main.xml, wenn der Benutzer die Taste drückt, sollte es das Fragment (genannt Radio-Fragment) zeigen, wenn ich das cardview immer noch zeige im Radio-Fragment (Fragment Name)Cardview wird auch im zweiten Fragment angezeigt
ich möchte die cardview und Taste verstecken und das Fragment zeigen, wenn der Benutzer die Taste drücken
hier meine Inhalte Haupt
ist<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.MainActivity"
tools:showIn="@layout/activity_main">
<android.support.v7.widget.CardView
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_marginTop="16dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:cardElevation="10dp" >
</android.support.v7.widget.CardView>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
hier ist die fragment_radio.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.Radio">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:animationResolution="@integer/abc_max_action_buttons"
android:clickable="false"
android:theme="@style/Base.Theme.AppCompat"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center" />
</RelativeLayout>
dies die Tastenfunktion in Haupttätigkeit ist
Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Radio radio=new Radio();
android.support.v4.app.FragmentManager manager=getSupportFragmentManager();
manager.beginTransaction().replace(R.id.Relative, radio,radio.getTag()).commit();
}
});
}
jemand kann mir helfen?
Button wird nicht im Fragment angezeigt, nur cardview –
ok. Ich denke, wenn Sie auf Android-Version> 5.0 laufen, werden beide sichtbar – arjun
Nun, was zu tun ist, wenn ich die Sichtbarkeit gegangen Option in der Tastenfunktion hinzufügen .. ist das in Ordnung? –