Activity transfer value to fragment

Source: Internet
Author: User

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);   Avatar
Bitmap BM = bitmapfactory.decodefile ("/sdcard/myheader/newpic.jpg"); Take pictures from the local (get in Cdcard) //
Touxiang. Setimagebitmap (Util.toroundbitmap (BM)); Set 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); Here use Startactivityforresult (intent,0); Transfer from fragment to activity

}
});
public void Onactivityresult (int requestcode, int resultcode, Intent data) {  //The things here are done at the end of the activity, can be passed, can be initialized.
Super.onactivityresult (Requestcode, ResultCode, data);
Bitmap BM = bitmapfactory.decodefile ("/sdcard/myheader/newpic.jpg"); Take pictures from the local (get in Cdcard) //
Touxiang. Setimagebitmap (Util.toroundbitmap (BM)); Set bitmap
}

Activity transfer value to fragment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.