简体   繁体   English

如何一次显示图像?

[英]How display image once?

May be need to keep some value in SharedPreferences? 可能需要在SharedPreferences中保留一些值?

XML XML格式

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_height="match_parent" 
  android:layout_width="match_parent" 
  android:id="@+id/fragment2_bacground" 
  android:foreground="@drawable/fragment2">    

Class

FrameLayout frameLayout;
frameLayout = (FrameLayout)rootViewB.findViewById(R.id.fragment2_bacground);

prefs = getActivity.getSharedPreferences("com.example.potehki.potehki", getActivity.MODE_PRIVATE);

This method does not work 此方法不起作用

if (prefs.getBoolean("firstrun", true)) { 
 frameLayout .setforeground(null);
 prefs.edit().putBoolean("firstrun", false).commit(); 
}

Any help is appreciated. 任何帮助表示赞赏。

Avoid using setForeground. 避免使用setForeground。

I will suggest to keep exactly the same logic just change from FrameLayout to ImageView (with src attribute) and instead of using frameLayout: 我建议保持完全相同的逻辑,只是从FrameLayout更改为ImageView(具有src属性),而不是使用frameLayout:

setforeground(null); setforeground(null);

Use: 采用:

imageView.setVisibility(View.GONE); imageView.setVisibility(View.GONE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM