开发者

queries on button operations of android

in the main activity of my app i have placed a button named as setting, if i click the button it moves to a new page where i have placed two buttons.

if i click in any of those buttons i want its corresponding operations to be done in another activity,how to do this...

in the same way if i click a button i开发者_StackOverflow中文版n Activity A, i need a button to be completely invisible in some other Activity...

how to do this....


The best way is to pass messages through the Intent that you use to start an activity. This answer gives a detailed code sample for this.


You can send some data along with the intent, which you used to start the other activity. For eg, in Activity A

Intent i = new Intent(this, B.class)
b.setBooleanExtra("isButtonVisible", false);
startActivity(i);

Now in Activity B, in it's onCreate() method, use

boolean isButtonVisible=getIntent().getBooleanExtra("isButtonVisible);
if(!isVisible)
button.setVisibility(View.INVISIBLE) //Or do something with that

I think you got the idea now?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜