当前位置: 首页 > news >正文

如何为网站添加谷歌分析工具html代码示例

如何为网站添加谷歌分析工具,html代码示例,注册网站一年多少钱,华为手机业务最新消息原文地址#xff1a;http://android.xsoftlab.net/training/basics/fragments/communicating.html 为了可以重复使用Fragment UI组件#xff0c;你应该将fragment构建为一个完整的独立的模块化组件#xff0c;并且它可以定义自己的布局和行为习惯。你只要定义了一次这类可复…原文地址http://android.xsoftlab.net/training/basics/fragments/communicating.html 为了可以重复使用Fragment UI组件你应该将fragment构建为一个完整的独立的模块化组件并且它可以定义自己的布局和行为习惯。你只要定义了一次这类可复用的fragment你就可以通过activity与之相关联然后使用应用程序逻辑与之建立连接以实现完整的复合型UI组件。 经常你会希望一个fragment对象可以和其它的fragment对象进行通信举个例子基于用户的事件更改内容。所有的fragment之间的通信都是通过它们关联的activity进行的。两个fragment对象应该永远不要直接通信。 定义一个接口 为了使fragment与其关联的activity建立通信渠道你可以在fragment中定义一个接口然后让activity实现它。这个fragment对象可以在生命周期方法onAttach中取得这个接口的实现然后就可以调用这个接口的方法与其关联的activity进行通信了。 下面是fragment与activity通信的例子 public class HeadlinesFragment extends ListFragment {OnHeadlineSelectedListener mCallback;// Container Activity must implement this interfacepublic interface OnHeadlineSelectedListener {public void onArticleSelected(int position);}Overridepublic void onAttach(Activity activity) {super.onAttach(activity);// This makes sure that the container activity has implemented// the callback interface. If not, it throws an exceptiontry {mCallback (OnHeadlineSelectedListener) activity;} catch (ClassCastException e) {throw new ClassCastException(activity.toString() must implement OnHeadlineSelectedListener);}}... } 现在fragment就可以通过调用OnHeadlineSelectedListener接口的具体实现对象mCallback的onArticleSelected方法(或者接口中的其它方法)给activity传送消息了。 举个例子下面这个方法会在用户点击列表条目的时候被调用然后fragment会使用回调接口将事件传送给它所附属的activity。 实现接口 为了可以从fragment中接收事件回调那么包含fragment的activity必须实现在fragment中定义的接口。 举个例子下面是上面例子中的在activity中的接口实现 public static class MainActivity extends Activityimplements HeadlinesFragment.OnHeadlineSelectedListener{...public void onArticleSelected(int position) {// The user selected the headline of an article from the HeadlinesFragment// Do something here to display that article} } 发送消息给fragment 宿主activity可以通过findFragmentById()方法获得fragment的对象然后再发送消息到fragment中。可以直接调用fragment的public方法发送消息。 举个例子想象上面例子中的activity可能还包含有其它的fragment这些fragment可能被用来显示上面回调方法返回的数据。在这个例子中activity会将从回调方法中接收到的信息传递给其它的fragment其它的fragment会将这些信息显示出来 public static class MainActivity extends Activityimplements HeadlinesFragment.OnHeadlineSelectedListener{...public void onArticleSelected(int position) {// The user selected the headline of an article from the HeadlinesFragment// Do something here to display that articleArticleFragment articleFrag (ArticleFragment)getSupportFragmentManager().findFragmentById(R.id.article_fragment);if (articleFrag ! null) {// If article frag is available, were in two-pane layout...// Call a method in the ArticleFragment to update its contentarticleFrag.updateArticleView(position);} else {// Otherwise, were in the one-pane layout and must swap frags...// Create fragment and give it an argument for the selected articleArticleFragment newFragment new ArticleFragment();Bundle args new Bundle();args.putInt(ArticleFragment.ARG_POSITION, position);newFragment.setArguments(args);FragmentTransaction transaction getSupportFragmentManager().beginTransaction();// Replace whatever is in the fragment_container view with this fragment,// and add the transaction to the back stack so the user can navigate backtransaction.replace(R.id.fragment_container, newFragment);transaction.addToBackStack(null);// Commit the transactiontransaction.commit();}} }
http://www.pierceye.com/news/192477/

相关文章:

  • 免费建站的手机app专业做网站设计公司价格
  • 江苏宜兴做网站的电话seo基础培训
  • 企业手机端网站模板下载济南公司建站模板
  • 一般公司做网站多少钱南昌市房产网
  • 惠州网站小程序建设做公司永久免费网站什么好
  • 湖南涟钢建设有限公司网站局网站建设工作总结
  • 家乡ppt模板免费下载网站合肥百姓网网站建设
  • 免费整套ppt模板下载网站东莞建设教育网站
  • 漯河网站建设漯河ps制作个人网站首页
  • 电商网站公司软件开发和软件研发
  • 网站建设浙江公司网站开发运营新人要注意什么
  • 外贸网站模板哪里下载家里电脑可以做网站服务器吗
  • 长沙门户网站北京设计网站的公司
  • 站长统计平面设计找工作难吗
  • seo建站公司推荐电商平台活动策划方案
  • 建设淘宝客网站.lc和ev手机对比平台
  • vue 做企业网站特产网站开发背景
  • 奉新网站制作dede视频网站源码
  • 做动画网站去哪采集建设网站需要的资金清单
  • 网站后台发邮件注册公司需要什么证件和手续
  • 炫酷特效网站万网虚拟主机免费空间
  • 公司网站模板最新怀远网站建设哪家好
  • 交互式网站定义如何网上找加工订单
  • 一个域名可以做几个网站吗南城网站建设公司
  • 宝安商城网站建设flash新手入门简单动画制作
  • 设置网站建设WordPress adsen
  • 网站与微信内容建设与运维总结建筑网络图
  • 网站模板文件不存在网站建设礻金手指下拉十二
  • 东莞浩智建设网站公司做百度推广员赚钱吗
  • qq网站推广代码昆明哪里做网站