源码:

         FragmentTransaction mFragmentTranscation = getSupportFragmentManager().beginTransaction();
Fragment mMainFragment = new MainFragment();//此行提示出错
mFragmentTranscation.replace(R.id.container, mMainFragment);
mFragmentTranscation.commit();

错误提示:无法将MainFragment (Fragment的子类)强制转换成Fragment

解决方法:

在原来的MainFragment中把

import android.app.Fragment;

更改为:

import android.support.v4.app.Fragment;

Type mismatch: cannot convert from MainFragment to Fragment 报错的更多相关文章

  1. Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement

    Connection.prepareStatement()函数出错,提示: Type mismatch: cannot convert from java.sql.PreparedStatement ...

  2. Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>

    完整的错误信息: Description Resource Path Location TypeType mismatch: cannot convert from Enumeration<St ...

  3. Type mismatch: cannot convert from javax.servlet.http.Cookie[] to org.apache.tomcat.util.http.parser.Cookie[] 的一种可能

    今天用到Cookie时,写了一个Cookie数组,发现报错“Type mismatch: cannot convert from javax.servlet.http.Cookie[] to org. ...

  4. 报错:Type mismatch: cannot convert from Object to Car

    问题描述: 一个非常简单的spring项目,用静态工厂方法配置bean实例.项目的目录结构如下: 代码如下: Car.java package com.tt.spring.beans.factory; ...

  5. java.lang.Error: Unresolved compilation problems: Syntax error on token "return", delete this token Type mismatch: cannot convert from Init to String

    java.lang.Error: Unresolved compilation problems:   Syntax error on token "return", delete ...

  6. input type=date时,时间数据回填,报错The specified value "2019-0404-18" does not conform to the required format, "yyyy-MM-dd".

    <input autocomplete id="start-time" name="start_time" type="date" c ...

  7. 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's parent first.

    在将一个fragment替换到一个frameLayout的时候报错: code: transaction.replace(R.id.fragment_container, fragment2); 错误 ...

  8. Type mismatch: cannot convert from element type Object to String 解决办法

    首先放上我的源码,看看你的代码是不是我这个类似的. @Test void predicateTest() throws Exception { List<String> languages ...

  9. The type org.springframework.jms.JmsException cannot be resolved报错解决

    在调用JmsTemplate的send方法时,一直报编译时异常.如下: 异常提示是无法解析org.SpringFrawork.jms.JmsException类型.如下: The type org.s ...

随机推荐

  1. 添加项目到远程服务器(git)

    搞开发经常会用到把代码提交到远程服务器,之前也是懵懂的.今天来整理了一下.具体操作如下: 1.进入到远程服务器 ssh name -- 远程服务器地址 2.进入以后新建一个空的仓库 git init ...

  2. Cookie——Javascript

    基本的cookie操作有三种:读取.写入.删除. var CookieUtil = { //根据cookie的name获取相应的value.它会在document.cookie字符串中查找cookie ...

  3. js中对象使用

    简单记录javascript中对象的使用 一.创建对象 //创建一个空对象 var o={}; //创建一个含有两个属性的对象,x.y var o2={x:12,y:'12',name:'JS'}; ...

  4. Flexslider - 响应式的 jQuery 内容滚动插件

    FlexSlider 是一款轻量的响应式 jQuery 内容滚动插件,能够帮助你在项目轻松的创建漂亮的内容滚动效果.这款插件曾经连续多年入选 WDL 的年度最佳 jQuery 插件,值得大家在网站开发 ...

  5. [deviceone开发]-viewShower和listView

    一.简介 viewshower里嵌套listview,实现复杂的列表效果. 二.效果图 三.相关下载 http://source.deviceone.net/source-detail.html?do ...

  6. 学习zepto.js(Hello World)

    Zepto是一个轻量级的针对现代高级浏览器的JavaScript库, 它与jquery有着类似的api. 如果你会用jquery,那么你也会用zepto. 昨天听说了zepto.js,正好最近也比较闲 ...

  7. SAP程序代码中RANGE表的用法禁忌

    最近经常有出现以上的SQL代码导致程序DUMP,SAP错误日志如下:       经过检查RANGE表GR_MATNR,当用于WHERE条件是,只限较小的数据量的情况(约100条左右): 若为大数据量 ...

  8. Wifite.py 修正版脚本代码

    Kali2.0系统自带的WiFite脚本代码中有几行错误,以下是修正后的代码: #!/usr/bin/python # -*- coding: utf-8 -*- """ ...

  9. 【Leafletjs】7.结合echart图表展示信息

    1.popup中添加图表信息 //定义marker var marker = L.marker(val.location).addTo(map); var content = '<div sty ...

  10. [Android]在Adapter的getView方法中绑定OnClickListener比较好的方法

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/4146512.html  给ListView中每个item绑定点 ...