Cannot Resolve Method Placeholderfragment Error
I'm really stuck on this error (below): @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.
Solution 1:
- You probably extending the wrong version of
Fragment
In your file PlaceholderFragment.java
, first make sure you extend Fragment
:
publicclassPlaceholderFragmentextendsFragment { //...
Then, check the imports at the beginning of that file. There should be the line:
import android.app.Fragment;
and NOT the line:
import android.support.v4.app.Fragment;
Try not to mix "normal" and "v4" Fragments, they have the same name and do the same things but they are actually different classes.
Solution 2:
I had to import android.support.v4.app.Fragment to fix this problem.
In my case I was using minSdkVersion 8 and I had created a Activity class java > Package > Acitivity > BlankActivity. This created activity class had a inner class public static class PlaceholderFragment extends Fragment. This inner class was used in onCreate() in
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
}
}
Post a Comment for "Cannot Resolve Method Placeholderfragment Error"