Fragment的显示问题 FragmentsetCustomAnimations 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要先将payProductFragment通过add方法添加到FragmentTransaction中,再调用hide和show才用效果。 add方法至少要两个参数,第二个参数是做什么用的,能写下吗?我是新手我参照的范例,没有用add方法,但能够正常执行hide和show方法...这是为什么 我大概明白你的意思,但这个payProductFragment是原来就包含在布局文件中,应该不用手动add吧 你可以将你的PayProductFragment(Fragment的继承类写在LinearLayout中通过visibility来设置,比如:<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout" android:visibility="gone" > <fragment android:id="@+id/book_list" android:name="com.example.book_activity.BookListFragment" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /></LinearLayout>然后在你的listView点击事件中调用LinearLayout linearLayout=(LinearLayout)findViewById(R.id.linearLayout);linearLayout.setVisibility(linearLayout.VERTICAL); 可是这样子太生硬了,用FragmentManager能够设置一些淡入淡出或左近右出这样的效果 android http连接电脑数据库的服务端怎样写? Android HOME键唤醒屏幕 使用soap2报错是怎么回事? android 动态布局 线性布局 为啥不显示? 想在eclipse下调试定制源码 导入工程代码问题 Android自定义类与Bitmap相同 500分求助 选择文字 弹出菜单 CTS使用Verifier.apk测试Data Backup Test 失败 大家开发时用模拟器还是连接到真机调试 使用SharedPreferences访问其他文件中的资源TextView报空指针错误 Android中调用系统相册后不选图片,直接点击取消崩溃!!!! 刮刮乐实例教程
我参照的范例,没有用add方法,但能够正常执行hide和show方法...这是为什么
我大概明白你的意思,但这个payProductFragment是原来就包含在布局文件中,应该不用手动add吧
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/linearLayout"
android:visibility="gone" >
<fragment
android:id="@+id/book_list"
android:name="com.example.book_activity.BookListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>然后在你的listView点击事件中调用
LinearLayout linearLayout=(LinearLayout)findViewById(R.id.linearLayout);
linearLayout.setVisibility(linearLayout.VERTICAL);
可是这样子太生硬了,用FragmentManager能够设置一些淡入淡出或左近右出这样的效果