如何保存更改的布局android?

时间:2015-08-17 23:23:42

标签: android android-layout

所以我有了一个带有imageView的布局。用户更改了imageView的图像(在另一个活动中发生,我将图像路径传递给此活动),然后我想保存布局。稍后,我想用改变后的ImageView调用该布局,我无法弄明白!有人可以帮助我吗?!?

@Override
public void onResume()
{
    super.onResume();
    ImagePath = getIntent().getStringExtra("imagePath");
    setContentView(R.layout.item);
    ImageView v = (ImageView) findViewById(R.id.maxCard);
    v.setImageBitmap(BitmapUtility.decodeSampledBitmapFromResource(ImagePath,500,500));
   //Now I want to save this layout!!! BUt i don't know how?!?

    setContentView(R.layout.activity_my);//My second layout
    al = new ArrayList<>();
    al.add("max");
    al.add("launcher");
    al.add("php");
    al.add("c");
    al.add("python");
    al.add("java");
    al.add("html");
    al.add("c++");
    al.add("css");
    al.add("javascript");
    arrayAdapter = new ArrayAdapter<>(this, R.layout.item, R.id.helloText, al);//HERE I WANT TO USE that changed layout by the user...
    flingContainer.setAdapter(arrayAdapter);

1 个答案:

答案 0 :(得分:0)

onResume()内而不是ImagePath = getIntent().getStringExtra("imagePath");执行ImagePath = prefs.getString("image_path_key","default_image_path");并在您的其他活动中,而不是在意图中传递图片路径,并使用相同的SharedPreferences密钥保存。