我正在为 Android 制作一个应用程序,但我很难保存ImageButton
单击它时的可见性。我搜索其他主题,但没有找到任何解决方案。
例如,我有一个按钮在单击时变为白色,我想在切换活动或视图时保存它的可见性:
OnClickListener oclFavourite = new OnClickListener() {
@Override
public void onClick(View arg0) {
ImageButton favWhite = (ImageButton) findViewById(R.id.favoriwhite);
ImageButton favori = (ImageButton) findViewById(R.id.favorigrey);
favWhite.setVisibility(View.VISIBLE); //The white button I want to save
favourite.setVisibility(View.INVISIBLE); //The initial button
}
};
favori.setOnClickListener(oclFavori);
我试图研究SharedPreferences
函数,我成功保存TextView
但我不知道如何继续ImageButton
or ImageView
。