Kevik
Kevik

Reputation: 9351

instantiation of FragmentTransaction object not possble according to the compiler, Android

when I try to instantiate FragmentTransaction() I the the error message:

"can not instantiate the type FragmentTransaction"

in google Android reference it states:

Public Constructors

FragmentTransaction()

so if there is a constructor of FragmentTransaction() then it must be possible to do this,

 FragmentTransaction fragtransaction = new FragmentTransaction();

the question is WHY is this not possible?

Upvotes: 2

Views: 175

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199825

FragmentTransaction, per the documentation, is an abstract class and therefore cannot be directly instantiated. Instead, you should use FragmentManager's beginTransaction method to get a valid FragmentTransaction

Upvotes: 3

Related Questions