无法解析的方法placeholderfragment错误 [英] Cannot resolve method placeholderfragment error
问题描述
我真的卡在这个错误(下):
I'm really stuck on this error (below):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vehiclerecall);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
我有正确引用到XML布局的容器(下):
I have the container referenced correctly to XML layout (below):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
tools:context="com.customerautomotivenetwork.VehicleRecall"/>
不过,我不断收到一个错误无法解决方法PlacehlderFragment,是我做错了什么想法?
But I keep getting an error of cannot resolve method for PlacehlderFragment, any idea of what I'm doing wrong?
推荐答案
- 您可能延长错版
片段
在文件 PlaceholderFragment.java
,首先要确保你延长片段
:
In your file PlaceholderFragment.java
, first make sure you extend Fragment
:
public class PlaceholderFragment extends Fragment { //...
然后,检查进口在该文件的开头。应该有一行:
Then, check the imports at the beginning of that file. There should be the line:
import android.app.Fragment;
和不会的行:
import android.support.v4.app.Fragment;
尽量不要混用正常和V4片段,它们具有相同的名字,做同样的事情,但它们实际上是不同的类。
Try not to mix "normal" and "v4" Fragments, they have the same name and do the same things but they are actually different classes.
这篇关于无法解析的方法placeholderfragment错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!