clicking on the fragment invokes activity behind it

后端 未结 5 1113
情书的邮戳
情书的邮戳 2021-01-01 16:31

Im guessing its something really simple, maybe a setting in listview or fragment. But I couldnt find solution for it for couple of hours now. So.. I have a listView like thi

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 17:18

    I believe the issue is that the replace method doesn't replace the ListView. It only replaces other fragments that are within the container. In this specific case there are none. Thus, you're essentially adding your fragment on top of the ListView because the RelativeLayout allows views to be on top of one another. When you click on the fragment, you're not fully handling it, so it goes through to the base view which is the ListView.

    A simple, quick, and dirty solution would be to retrieve the ListView object and either remove it from the container yourself or set it's visibility to GONE. A better solution would be to use ListFragment which should show the expected results.

提交回复
热议问题