Fragment之间传值CallBack(Fragment01)
来源:互联网 发布:淘宝店铺装修哪里有 编辑:程序博客网 时间:2024/06/07 10:38
package com.bwie.fragmentcallback;import android.content.Context;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.ListView;/** * Created by Shadow on 2017/7/11. */public class Fragment01 extends Fragment { callBack cb; private View view; private String[] mStrings = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", "Allgauer Emmentaler", "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", "Allgauer Emmentaler"}; public interface callBack{ public void setTitle(String title); } @Override public void onAttach(Context context) { cb= (callBack) context; super.onAttach(context); } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment1, container, false); return view; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ListView listview = (ListView) view.findViewById(R.id.listview); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,mStrings); listview.setAdapter(adapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String s = mStrings[i]; cb.setTitle(s); } }); }}
阅读全文
0 0
- Fragment之间传值CallBack(Fragment01)
- Fragment之间传值CallBack(Fragment02)
- Fragment之间传值CallBack(MainActivity)
- Fragment01
- Fragment之间传值
- Fragment之间传值
- Fragment之间传值
- Fragment 之间传值
- Fragment 之间的传值
- Fragment之间传值(第三周周考)
- activity嵌套fragment,fragment内嵌fragment之间传值切换fragment
- Activity和Fragment之间的传值
- Fragment与Activity之间传值
- Android fragment 之间传值的方法
- android中fragment之间传值
- Activity与Fragment之间的传值
- Fragment之间传值的方法
- DialogFragment与Fragment之间互相传值
- 如何把window 7共享盘挂载到centos6.5
- 线性CCD图像处理与二值化
- 编程中设计并发服务器,使用多进程和多线程,请问有什么区别?
- python基础之杂文
- placeholder字体颜色怎么设置修改&placeholder字体颜色怎么设置修改
- Fragment之间传值CallBack(Fragment01)
- servlet
- PHP学习路线
- android Studio无法创建项目问题与解决
- C++引用折叠
- 战斗“盛大游戏杯”第15届上海大学程序设计联赛夏季赛暨上海高校金马五校赛
- html添加空格
- 最大流问题Ford-Fulkerson算法
- BZOJ 1222: [HNOI2001]产品加工