Why Listfragment Scroll The List Behind The View And I See Duplicate The Elements?
Solution 1:
I have to change my answer. I don't think the ListView
is duplicated. Either version of the fragment creation code should work fine. I think the problem is that your Fragment
is duplicated.
I didn't look carefully enough at listview.xml. You already declared a FavouritesActionBar
fragment in listview.xml, yet in your code you create another one and are trying to replace the declared one. This is redundant.
I remember seeing some comments about how it's not good to mix XML-declared fragments with coded fragments. I can't find the reference to that, but I can tell you that every time I've tried to do something like what you're doing, I've gotten into trouble. Now I always just declare empty container ViewGroup
s in XML and do fragment transactions on them in the code.
You have two choices:
Use the coded fragment and change your listview.xml to this:
<?xml version="1.0" encoding="utf-8"?><FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/fragment_place"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"/>
or
Use the XML-declared fragment and change your
onCreate()
to this:@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview); }
Post a Comment for "Why Listfragment Scroll The List Behind The View And I See Duplicate The Elements?"