我正在尝试创建recyclerview
个应用。然后我在我的最后一页(detailedactivity.java
)上创建一个随机图像按钮。当我点击按钮然后我的图像随机变化但最后它不会返回我的主页我该怎么办?
当我再次进入我的应用程序时,我仍然看到那里的随机图像。没有主页和主图像。
这是我的代码:
Bundle mBundle = getIntent().getExtras();
if (mBundle != null) {
mToolbar.setTitle(mBundle.getString("Title"));
mFlower.setImageResource(mBundle.getInt("Image"));
mDescription.setText(mBundle.getString("Description"));
}
showRandomFact();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showRandomFact();
}
});
}
private void showRandomFact() {
shuffleFacts();
mFlower.setImageResource(factArray[0].getivImage());
mDescription.setText(factArray[0].getmFact());
}
Facts f01 = new Facts(R.drawable.a,"hjgbfvjhsdbfvskhbsdıkfvsdkb");
Facts f02 = new Facts(R.drawable.aa,"hjgbfvjhsdbfvskhbsdıkfvsdkb");
Facts f03 = new Facts(R.drawable.aas,"hjgbfvjhsdbfvskhbsdıkfvsdkb");
Facts[] factArray = new Facts[] {
f01,f02,f03
};
public void shuffleFacts(){
Collections.shuffle(Arrays.asList(factArray));
}
}