2
하나의 안드로이드 응용 프로그램을 개발해야합니다.안드로이드에서 볼 수 있고 조각을 사라졌다
값을 확인해야합니다. 값이 Null 인 경우 fragment.otherwise visible.how visible을 숨길 수 있습니다. 어떻게 할 수 있습니까 ???
날이에 대한 해결책 .. 나는 이러한 활동에 조각을 숨길 수있는 방법
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); } else { \t fragment.setVisibility (View.VISIBLE); }이 줄에서 다음과 같은 오류가 발생하고 있음을 의미합니다. YouTubePlayerSupportFragment 유형에 대해 setVisibility (int) 메소드가 정의되지 않았습니다. – user2218667
이 조각에 대해 별도의 레이아웃을 만들고 해당 레이아웃에 대해 GONE 및 VISIBLE 기능을 수행했습니다. 이제 알았어. 고마워. – user2218667