• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Fragment does not recognize any Activity

I have created a bottom navigation activity with three fragments using templates from Android Studio.

In the first Fragment of this bottom navigation activity, has a Listiview with many items. I need to redirect the user to another activity when he clicks on an item, but the fragment doesn't show any Activity file when insert the Intent code, just Java files.

This my code below:

Java:
mRef.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
                Product product = dataSnapshot.getValue(Product.class); // My class Product

                products.add(product); // Adding product to Array products
                adapter.notifyDataSetChanged();
                TextView txtNameUserApp = (TextView) getActivity().findViewById(R.id.txtNameUserApp);
                ImageView imgUserApp = (ImageView) getActivity().findViewById(R.id.imgUserApp);
                ClasseFirebase.getDataUser(txtNameUserApp, imgUserApp, mAuth, getContext());

                // Setting the Itemclick of the ListView lstvProducts
                lstvProducts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        startActivity(new Intent(getActivity(), MinhaActivty.class)); // In this place I need to insert the name of another activity
                    }
                });
            }

Can anyone tell me why?
 
  • Like
Reactions: Ralph macias
I only realized this after post the question and I don't know how to delete or switch the board of the post.
I'll have it moved for you. Or you can copy/paste it into a new post. If you're going to do that, you need to be in 'edit' mode to copy everything, including its formatting. You can edit a post by clicking 'Tools > Edit' and go from there!
 
  • Like
Reactions: RioLeal
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones