zoukankan      html  css  js  c++  java
  • activity传值到fragment

    public class MyFragment extends Fragment {   //FragmentActivity

    public static MyFragment staticInstance = null;

    public static MyFragment getInstance() {
    if (staticInstance == null){
    staticInstance = new MyFragment();
    }
    return staticInstance;
    }
    ImageView Touxiang,Lianxifangshi,Changyongdidian,Fuwuquyu,Yijianfankui,Changjianwenti;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view=inflater.inflate(R.layout.mygelin,container,false);
    Touxiang=(ImageView)view.findViewById(R.id.Touxiang);   //头像
    Bitmap bm = BitmapFactory.decodeFile("/sdcard/myheader/newpic.jpg"); //从本地取图片(在cdcard中获取) //
    Touxiang .setImageBitmap(Util.toRoundBitmap(bm)); //设置Bitmap

    Touxiang.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v){
    Intent intent=new Intent();
    // intent.setClass(MyFragment.this, NMainActivity.class);
    intent.setClass(getActivity(),NMainActivity.class);
    startActivityForResult(intent,0); //这里使用startActivityForResult(intent,0); 从Fragment调到activity

    }
    });
    public void onActivityResult(int requestCode, int resultCode, Intent data){  //这里的东西是activity结束时进行的,可以传值,可以进行初始化。
    super.onActivityResult(requestCode, resultCode, data);
    Bitmap bm = BitmapFactory.decodeFile("/sdcard/myheader/newpic.jpg"); //从本地取图片(在cdcard中获取) //
    Touxiang .setImageBitmap(Util.toRoundBitmap(bm)); //设置Bitmap
    }
  • 相关阅读:
    JSP的组成
    什么是JSP
    JSP和Servlet分工图
    Linux逻辑卷管理LVM2详解
    ESXi主机和NTP server快速进行时间同步
    VMwareCLI命令参考
    使用Logminer工具分析DML和DDL操作
    TKPROF使用
    iSCSI存储设备的udev绑定 以及iscsi重启卡住解决方法
    Oracle 10g EM证书问题
  • 原文地址:https://www.cnblogs.com/to-creat/p/5149865.html
Copyright © 2011-2022 走看看