使用fragmenttabhost后,子fragment怎么获取ID?怎么用getSharedPreferences

public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View parentView = inflater.inflate(R.layout.fragment1, container, false);

        SharedPreferences pre = getActivity().getSharedPeferences(CFG,0);
               //getSharedPeferences("myinfo",Context.MODE_PRIVATE);

        return parentView;

    }
时间: 2024-08-26 17:55:27

使用fragmenttabhost后,子fragment怎么获取ID?怎么用getSharedPreferences的相关文章

Android fragment 获取id,findViewById为空

项目中需要保持标题栏,通过点击标题栏左侧的按钮,弹出下拉菜单,切换右侧的界面,所以就想到使用fragment这个类,可以很好的切换activity,不过在使用的时候还是出现了很多问题: 1 .public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View vi = inflater.inflate(R.layout.activity_price, co

父兄子节点的获取及子节点的添加、删除、克隆操作

第一.父兄子节点的获取 1.父节点的获取 某节点的parentNode属性值即为该节点的父节点.示例: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <body> <div id="father"> <div id="son1"></div> </

获取 id parentId 递归获取所有

Declare @Id Int Set @Id = 5;    ---在此修改父节点  With RootNodeCTE(Id,ParentId)  As (  Select Id,ParentId From BOM Where ParentId In (@Id)  Union All Select BOM.Id,BOM.ParentId From RootNodeCTE  Inner Join BOM On RootNodeCTE.Id = BOM.ParentId  )  Select * 

mybatis+mysql insert添加数据后返回数据主键id

1.根据useGeneratedKeys获取返回值,部分数据库不支持 修改mybatis xml <insert id="insertUser" useGeneratedKeys="true" keyProperty="id" parameterType="com.entity.user"> insert into test (name) values (#{name}) </insert> useGe

jquery 获取子iframe和获取父框架的例子

今天做前端页面设计,用到了iframe,查找资料,整理出来几个用jquery 获取子iframe和获取父框架的例子,用起来非常方便. 在firefox最新版(41)和IE9下测试通过.jquery 版本11.3. //获取子框架coverIframeFormTargetId中ID为attachment_Cover_Image_id的value的值 var attid =$("#coverIframeFormTargetId").contents().find("#attach

转:iframe加载的子页面里面获取父级元素窗口以及元素的高度

iframe里的js要操作父级窗口的dom,必须搞懂几个对象: parent是父窗口(如果窗口是顶级窗口,那么parent==self==top) top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe) self是当前窗口(等价window) 父级页面:index.html <!doctype html> <html> <head> <meta charset="utf-8"> <title>父窗口<

DOM操作 、js获取id的内容 和修改原来的内容(innerHTML)

js获取id的内容(getElementById) 和修改原来的内容(innerHTML) 1.通过ID获取元素 学过HTML/CSS样式,都知道,网页由标签将信息组织起来,而标签的id属性值是唯一的,就像是每人有一个身份证号一样,只要通过身份证号就可以找到相对应的人.那么在网页中,我们通过id先找到标签,然后进行操作. 语法: document.getElementById(“id”)   看看下面代码: 结果:null或[object HTMLParagraphElement] 注:获取的元

EC2.0开启多规格后,编辑无法获取规格数据

我们其实一共碰到2个问题, 1. 一个是弹出了货品编辑画面,但是货品的明细没有2.有货品明细但是货品明细各个字段都是空的, 上面2种情况数据库都是有值的. 第一个问题解决方案: 修改html中的JS app/b2c/view/admin/goods/detail/spec/set_spec.html 这个文件 修改 var activeProducts = <{$activeProducts}>; 为 : var activeProducts = New String(<{$active

Fragment中获取Activity的Context (转)

Fragment中获取Activity的Context时只需要this.getActivity()即可.     而不是许多人说的this.getActivity().getApplicationContext(),如果用后者传入AlterDialog肯定会报错(android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application).    因为只有ac