Fragment overlapping one on another in android -


i fetching data in list view using fragment mysql , here button on upper side when used click on button doesn't replace fragment overlaps in 1 before , after clicking on button.

here code fetching data in list view format , on click button open new fragment overelapping.

public class playquiz extends fragment{  public string subject;  string myjson; private static final string tag_results = "result";   private static final string tag_name = "subname";  string selcsub; button b1;  jsonarray peoples = null; arraylist<hashmap<string, string>> personlist;  listview list; textview ss,name;  inputstream = null; string res = null; string line = null;  @override public view oncreateview(layoutinflater inflater,         @nullable viewgroup container, @nullable bundle savedinstancestate) {     // todo auto-generated method stub     view rootview = inflater.inflate(r.layout.play_quiz, container, false);      list = (listview) rootview.findviewbyid(r.id.listview);     ss = (textview) rootview.findviewbyid(r.id.textview1);     b1 = (button) rootview.findviewbyid(r.id.button1);      b1.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view arg0) {             // todo auto-generated method stub                 playquizsubjectwise fragmentmanager = new playquizsubjectwise();//.begintransaction();                 fragmenttransaction fragmenttransaction = getfragmentmanager().begintransaction();                 fragmenttransaction.replace(r.id.playsubjectwise, fragmentmanager);                 fragmenttransaction.addtobackstack(null);                 fragmenttransaction.commit();         }     }); } 

main list xml file

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.sarvashikshan.playquiz"  android:background="#dcdcdc" android:id="@+id/playsubjectwise">  <textview     android:id="@+id/textview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="select subject"     android:textappearance="?android:attr/textappearancemedium" />  <listview     android:id="@+id/listview"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/textview1"     android:layout_below="@+id/textview1"     android:layout_margintop="16dp" > </listview>  <button     android:id="@+id/button1"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparenttop="true"     android:layout_alignright="@+id/listview"     android:layout_marginright="44dp"     android:text="button" /> </relativelayout> 

here list xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"  android:background="#dcdcdc" >  <textview     android:id="@+id/name"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="large text"     android:textappearance="?android:attr/textappearancelarge" />  </linearlayout> 

playquizsubjectwise xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" >  <textview     android:id="@+id/textview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_margintop="31dp"     android:textappearance="?android:attr/textappearancemedium" />  <textview     android:id="@+id/textview3"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbaseline="@+id/textview1"     android:layout_alignbottom="@+id/textview1"     android:layout_marginleft="35dp"     android:layout_torightof="@+id/textview1"     android:textappearance="?android:attr/textappearancemedium" />  <radiogroup     android:id="@+id/radiogroup1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/textview1"     android:layout_below="@+id/textview1"     android:layout_margintop="45dp" >      <radiobutton         android:id="@+id/radio0"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:checked="true" />      <radiobutton         android:id="@+id/radio1"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />      <radiobutton         android:id="@+id/radio2"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />      <radiobutton         android:id="@+id/radio3"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />  </radiogroup>  <button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparentright="true"     android:layout_below="@+id/radiogroup1"     android:layout_margintop="78dp"     android:text="next" />  <button     android:id="@+id/button2"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/button1"     android:layout_below="@+id/button1"     android:text="finish" />  </relativelayout> 

your second fragment's parent layout must have background.

playquizsubjectwise xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#fff"                                        //here     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin" > 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -