I am creating a framelayout pro-grammatically. Then I create fragment pro-grammatically..Then I want to add the fragment to the framelayout.. this process is happens every time when I click the button. For the framelayout id and fragment tag I created a integer increment variable("id" is initiated as to "0" when beginning)..
When very time I click the button new framelayout with new id create, create fragment with new tag, fragement is added to that framelayout...And contentious overlapping views..
Here below my code,
public void add_tab(View view)
{
id++;
String b = String.valueOf(id);
tab_frame = new FrameLayout(this);
FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT,Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
tab_frame.setLayoutParams(layoutparams);
tab_frame.setId (id);
FragmentManager fragment_manager1 = getSupportFragmentManager (); // fragment manager for dealing with fragments
frag_one frag_one_obj = new frag_one(); // creating a onj of fragment "frag_one"
FragmentTransaction fr_transaction = fragment_manager1.beginTransaction ();
fr_transaction.add (tab_frame.getId (),frag_one_obj,b);
fr_transaction.addToBackStack ("Fragment Add");
fr_transaction.commit ();
frag_one_obj.setArguments (bundle);
tab_frame.setVisibility (View.VISIBLE);
}
When I debug I am getting this error in logcat,
No view found for id 0x1 (unknown) for fragment frag_one{42bb0cc8 (d45032ae-5aa4-485f-87a6-da20f3d5ce1f) id=0x1 1}
Idon't know why that happens..I am already creating framelayout and assign a id for that..But this error tells there is no view assgned to this perticular id, so Fragment can't be added..
Pls help me.. Thanks in advance..