2
我必须开发一个android应用程序。可见和去掉了片段在android
在这里,我必须检查value.If值为空意味着必须隐藏fragment.otherwise可见的片段。我该怎么办?
请给我这些解决方案..
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); }意味着在这些行上出现以下错误:方法setVisibility(int)未定义为类型YouTubePlayerSupportFragment – user2218667 2013-05-06 13:55:04
我为这些片段创建了单独的布局,并且也为该布局完成了GONE和VISIBLE功能。现在我明白了。谢谢。 – user2218667 2013-05-07 03:39:05