am working on android application in which there is two activity that is main activity and mode activity. my first activity is main activity have some invisible icon, and second activity is mode activity .when i click on button in my second activity i cam back my first activity i want that invisible icon should visible.
enter code here
pro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
autobtn.setImageResource(R.drawable.auyto);
pro.setImageResource(R.drawable.proactiv);
Intent it = new Intent(ModeActivity.this, Mainactivity.class);
startActivity(it);
}
});
you can hide view using
yourView.setVisibility(View.GONE);
You can get the reference to your view by using findViewByID :) and when you want to get it back just say yourView.setVisibility(View.VISIBLE);
As per your question,in your Mode activity's onCreate or onStart you can hide your invisible icons like
@Override
protected void onStart(){
super.onStart();
yourView.setVisibility(View.GONE);
}
and in onClickListener of the button of your mode activity you can make the button visible. In onclickListener of your button put the code
yourView.setVisibility(View.VISIBLE);
Thats all.If you want the icons to appear and hide on alternate taps on same button (use button like toggle) then put the below code
if (yourView.getVisibility() == View.VISIBLE) {
yourView.setVisibility(View.GONE);
} else {
// Either gone or invisible
yourView.setVisibility(View.VISIBLE);
}
Hope it helps :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments