i'm building bookstore app
i have fragments every fragment is a section
and each fragment have a Fragment class and FragmentViewModel xlass
screen shot from fragment classes
this howthe app work i want to replace the text with list view
ready made fragment - YouTube[
^]
also i have adapter class and item class and
it's work fine in main activity
adapter and items class
What I have tried:
i added this code to ViewModel class but this code need to extends AppCompatActivity
when the fragment need to extends ViewModel
and this code work fine in main activity
<pre>ArrayList<Books_item> items = new ArrayList<>();
BooksAdapter adapter;
ListView listView;
private DrawerLayout nDrawerLayout;
private ActionBarDrawerToggle nToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = findViewById(R.id.book_list);
items.add(new Books_item("اbook name", "author", 244, (float) 3.5, "book type", R.drawable.picture, 25));
items.add(new Books_item("اbook name", "author", 244, (float) 3.5, "book type", R.drawable.picture, 25));
items.add(new Books_item("اbook name", "author", 244, (float) 3.5, "book type", R.drawable.picture, 25));
items.add(new Books_item("اbook name", "author", 244, (float) 3.5, "book type", R.drawable.picture, 25));
adapter = new BooksAdapter(this, 0, items);
listView.setAdapter(adapter);
}