大家都应该知道微信可以自由设置聊天的背景图片。现在我做一个试验,两个Activity,activity1和activity2.activity1用于让用户随即的更改activity2的背景图片(从相册选)。这个怎么实现啊。要退出之后再进去activity2的背景图片还是用户选的那个。

解决方案 »

  1.   

    从相册取出数据,转换成drawable格式的数据就可以的
      

  2.   

    activity1从相册中取出所选图片的路径path,把path传给activity2,activity2根据path读取本地图片进行显示就好了,再用SharedPreferences把path保存起来,下次进来从SharedPreferences读取path这样退出去 再进来也能显示开始选择的图片
      

  3.   


    settings = getSharedPreferences("appSetting", MODE_PRIVATE);
    layoutInflater = LayoutInflater.from(this);
    String tempSet = settings.getString("colorSet", "false");
    if(!"false".equals(tempSet)){
    View setView = layoutInflater.inflate(R.layout.set, null);
    String pathTemp = getPath(tempSet);
    ImageView imgSet = (ImageView) setView.findViewById(R.id.set_img);
    LinearLayout linerSet = (LinearLayout) setView.findViewById(R.id.set_liner);
    Bitmap bm = BitmapFactory.decodeFile(pathTemp);
    Log.e("path", pathTemp);
    Drawable dr = new BitmapDrawable(null, bm);
    linerSet.setBackgroundDrawable(dr);
    imgSet.setImageBitmap(bm);
    ///linerSet.setBackgroundColor(Color.YELLOW);   ///////①
    }我这么写怎么没有反应呢?①是用来测试的。我在if里面只给linerSet给一个Yellow的背景色,也是有的时候可以有的时候不行啊。。为什么啊?
      

  4.   

    有很多方法,你把设置了哪个图片,把它的索引或者路径存在SharedPreferences,下次登录,先去取