带数据的Intent
发送1界面
startActivityForResult(intent, 2);传入参数
onActivityResult重写此方法接受
界面2接受
Intent intent = new Intent();
intent.putExtra("name", trim);
intent.putExtra("paw", trim2);
setResult(119,intent);
finish();
int level = animationDrawable.getLevel();
Log.e("tag",level+"level" );//获得等级0
int opacity = animationDrawable.getOpacity();
Log.e("tag",opacity+"opacity" );//-1Opacity不透明度
getNumberOfFrames();//返回的是都少个帧
发送
BitmapDrawable bd=(BitmapDrawable)current;
Bitmap bitmap = bd.getBitmap();
d.add(bitmap);
Intent intent = new Intent(MainActivity.this,
Main2Activity.class);
intent.putExtra("current",d);
startActivity(intent);
接受
Intent intent = getIntent();
ArrayList<Bitmap> list =(ArrayList<Bitmap>)intent.getSerializableExtra("current");
Log.e("tag", list.get(0)+"");
if (imageview!=null) {
imageview.setImageBitmap(list.get(0));
}
在清单中
设置切换屏幕方向是保留Activity数据,就不会走新建和销毁
参数1是页面的方向2是硬件3是屏幕尺寸android:configChanges="orientation|keyboardHidden|screenSize"
设置横屏强制
android:screenOrientation="landscape"
设置横屏竖屏切换
public void button_hen(View v){
//1得到方向
int orientation = getResources().getConfiguration().orientation;
//判断是否是竖屏
if(orientation==Configuration.ORIENTATION_PORTRAIT){
//竖屏就变成横屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}else{
//横屏就变成竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
自定义抽屉
https://blog.csdn.net/huwenzhi1991/article/details/46337295
设置Activity和Fragment传递数据
Fragment用getactivity获取Activity的操作
Activity通过text_fragment1.setArguments(bundle);然后再碎片类Bundle arguments = getArguments();用Bundle 添加数据