Reputation: 1292
I am trying call a New "FoodMenuFragmentDetail1" fragment from a fragment but whenever i click on button its go on next fragment but not shown on screen. what is the problem? here code how i call fragment.. Both layouts are linearlayout
@Override
public void onClick(View v) {
int sss=0;
String vvv=String.format("%03d", view.getId());
Fragment newFragment = new FoodMenuFragmentDetail1();
Bundle bundle = new Bundle();
bundle.putInt("ssss", sss);
bundle.putString("vvvv", vvv);
newFragment.setArguments(bundle);
FragmentTransaction transaction = getActivity()
.getSupportFragmentManager()
.beginTransaction();
transaction.replace(R.id.Foodmain,
newFragment);
transaction.addToBackStack("--");
transaction.commit();
}
oncreate function in FoodMenuFragmentDetail1
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.food_menu_fragment_detail,
container, false);
aq = new AQuery(getActivity(), view);
lv = (ListView) view.findViewById(R.id.price_list);
Foodbaricon = (TextView) view.findViewById(R.id.fav_star);
dialog = new ProgressDialog(getActivity(),
ProgressDialog.THEME_HOLO_DARK);
dialog.setMessage("Loading...");
dialog.setCancelable(true);
return view;
}
layout of FoodMenuFragmentDetail1
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical" >
</LinearLayout>
Upvotes: 1
Views: 2863
Reputation: 1292
i got solution. First Fragment Layout Changed from LinearLayout to FrameLayout and then replace with Second Fragment Layout and Now its working
Upvotes: 3
Reputation: 12943
You place the Fragment in the container with the id R.id.Foodmain
, but in your layout the container has the id layout_container
. If this is the right code change the id in your FragmentTransaction.
Upvotes: 0