这是我的代码:
private Button.OnClickListener gotologinpage3 = new Button.OnClickListener() {
public void onClick(View v) {
try {
Intent ii = new Intent(v.getContext(), login_profile.class);
startActivityForResult(ii,0);
}
catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
};
我可以将按钮 ID 传递给类 login_profile 中的函数 makenewProfile 吗?
最佳答案
是的,您可以添加extras
:
Intent ii = new Intent(v.getContext(), login_profile.class);
ii.putExtra("id", myId);
startActivityForResult(ii, 0);
然后像这样捡起来:
Bundle extras = getIntent().getExtras();
int id = extras.getInt("id");
关于android - 在android中传递按钮id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2228384/