Posts

Showing posts with the label android-fragments

Items in RecyclerView in a Fragmnet don't appear

Image
Items in RecyclerView in a Fragmnet don't appear I saw there are similar post but my code is the same as the codes in the solutions so they weren't useful in my case. My app starts but and two tabs are shown. However the one that is supposed to show the items from a RecyclerView that's in it is empty.I also get this error: E/RecyclerView: No adapter attached; skipping layout So I have an Activity with a TabLayout and a ViewPager public class MainActivity extends AppCompatActivity { TabLayout tabLayout; ViewPager viewPager; PagerAdapter pagerAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabLayout=findViewById(R.id.tab_layout); viewPager=findViewById(R.id.view_pager); tabLayout.addTab(tabLayout.newTab().setText("CitiesFragment")); tabLayout.addTab(tabLayout.newTab().setText("My CitiesFragme...

how to call method of one fragment from another fragment class in android

how to call method of one fragment from another fragment class in android I want to call a method of FragmentB (Class) from a fragmentA I tried by making a object of fragmentb in fragmentA (class) but it's not working here is the code of fragmentA in this class I have a method through which I will call the method of FragmentB class adddata.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { boolean isInserted = myDb.addalldata(monthly_income.getText().toString(), room_rent.getText().toString(), mess_rent.getText().toString()); if (isInserted = true) Toast.makeText(getActivity().getBaseContext(), "Data Inserted", Toast.LENGTH_LONG).show(); else Toast.makeText(getActivity().getBaseContext(), "Data not Inserted", Toast.LENGTH_LONG).show(); } } ); I want to call this method of fragmentB public void s...

How to increase the the limit of items showing in recyclerView

How to increase the the limit of items showing in recyclerView Basically I have made a RecyclerView in which I am showing all my data. At this stage code is working properly, data is showing in RecyclerView . But this is showing only nine items in the RecyclerView , not showing more. My data is greater than 9, how will I increase the limit of my data showing? RecyclerView RecyclerView RecyclerView in my fragment I have set data in recyclerView as private void setInfo(ArrayList<CategoriesItem> arrayListCategory){ categoriesAdapter = new CategoriesAdapter(context, arrayListCategory); rvCategories.setLayoutManager(new GridLayoutManager(context, 2,GridLayoutManager.VERTICAL,false)); rvCategories.setAdapter(categoriesAdapter); categoriesAdapter.notifyDataSetChanged(); } and mt adapter is public class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolder> { private ArrayList<CategoriesItem> categories; private Context...

Show a Fragment in FrameLayout without element in layout editor?

Show a Fragment in FrameLayout without <fragment> element in layout editor? I know that tools:layout can be used to show a fragment in <fragment> elements in the Android Studio's layout editor . tools:layout <fragment> However, I want to add a fragment in a FrameLayout at runtime (so that I can change the fragment). Similar questions found in SO like Question 1 and Question 2, but the answers in the pages cannot solve the problem exactly. What I want to do is: <fragment> <include> tools:layout <fragment> View.isInEditMode By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.