Мне нужно разработать одно приложение для Android.Видимый и ушел фрагмент в android
Здесь я должен проверить значение. Если значение Null означает, нужно скрыть фрагмент. В другом случае можно увидеть фрагмент. Как я могу это сделать ???
пожалуйста, дайте мне решение для них ..
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
YouTubePlayerSupportFragment fragment = new YouTubePlayerSupportFragment();
fragmentTransaction.add(R.id.youtube_fragment, fragment);
fragmentTransaction.commit();
_Video = articlevideo.substring(1);
fragment.initialize(DeveloperKey.DEVELOPER_KEY, new OnInitializedListener() {
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.cueVideo(_Video);
}
}
@Override
public void onInitializationFailure(Provider arg0,
YouTubeInitializationResult arg1) {
}
});
String vid = "Null";
if(_Video.equalsIgnoreCase(vid))
{
//Gone the fragment
}
else
{
//Visible the fragment
}
Как я скрыть фрагмент на эти активности ...
Это мой файл макета:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#414042"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#414042"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
<fragment
android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment"
android:id="@+id/youtube_fragment"
android:layout_width="match_parent"
android:layout_below="@+id/title"
android:layout_height="wrap_content"/>
<WebView
android:id="@+id/fullcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#414042"
android:layout_below="@+id/youtube_fragment"
/>
</RelativeLayout>
</RelativeLayout>
Как может я скрываю фрагмент ??? пожалуйста, дайте мне решение ???
String vid = "Null"; if (_Video.equalsIgnoreCase (vid)) { fragment.setVisibility (View.GONE); { \t fragment.setVisibility (View.VISIBLE); } означает, что появляется следующая ошибка в этой строке: метод setVisibility (int) не определен для типа YouTubePlayerSupportFragment – user2218667
. Я создал отдельный макет для этого фрагмента, а также сделал GONE и VISIBLE functionlaity для этого макета. Теперь я получил это. – user2218667