java-无法解决方法placeholderfragment错误

java-无法解决方法placeholderfragment错误,第1张

概述我真的被这个错误困住了(如下):@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_vehiclerecall);if(savedInstanceState==null){getFragmen

我真的被这个错误困住了(如下):

     @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布局的容器(如下):

<?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的方法,我在做什么错吗?

解决方法:

>您可能扩展了错误版本的Fragment

在文件PlaceholderFragment.java中,首先确保扩展Fragment:

public class PlaceholderFragment extends Fragment { //...

然后,检查该文件开头的导入.应该有这行:

import androID.app.Fragment;

而不是这行:

import androID.support.v4.app.Fragment;

尽量不要混合使用“正常”片段和“ v4”片段,它们具有相同的名称和相同的功能,但实际上它们是不同的类.

总结

以上是内存溢出为你收集整理的java-无法解决方法placeholderfragment错误全部内容,希望文章能够帮你解决java-无法解决方法placeholderfragment错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1088178.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存