解决方案 »

  1.   

    你要先将payProductFragment通过add方法添加到FragmentTransaction中,再调用hide和show才用效果。
      

  2.   

    add方法至少要两个参数,第二个参数是做什么用的,能写下吗?我是新手
    我参照的范例,没有用add方法,但能够正常执行hide和show方法...这是为什么
      

  3.   


    我大概明白你的意思,但这个payProductFragment是原来就包含在布局文件中,应该不用手动add吧
      

  4.   

    你可以将你的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);
      

  5.   


    可是这样子太生硬了,用FragmentManager能够设置一些淡入淡出或左近右出这样的效果