标签:
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
}
标签:
原文地址:http://www.cnblogs.com/to-creat/p/5149865.html