这是我的登录表格有效的意思是:
if(isUserValidated && isPasswordValidated)
{
if(DetailProductDescription.product_id==null){
Intent intent = new Intent(LoginForm.this,HomePage.class);
startActivity(intent);
}
else
{
Intent intent = new Intent(LoginForm.this,WatchList.class);
startActivity(intent);
}
}
修改
在这里,我必须检查其他部分中的另一个条件:
在其他部分必须检查另一个条件:
如果在没有登录的情况下获取DetailProductDescription页面上的product_id:
DetailProductDescription类只有这两个按钮。他们是关注列表和心愿单。
如果我必须单击DetailProductDescription.class上的监视列表按钮,则表示它转到WatchList类。
如果我必须单击DetailProductDescription.class上的wishlist按钮,则意味着它转到
new AddToWishListAsync()。execute();类。
如何识别LoginForm上的这些DetailProductDescription.watchlist和DetailProductDescription.wishlist按钮以及如何为这些写入条件?
请为我提供解决方案。
答案 0 :(得分:2)
所以你的问题是,
按钮关注列表 - >登录类 - > WatchList类
Button wishlist - >登录类 - > AddToWishListAsync class
'登录'必须识别哪个按钮。
不是吗?
我建议多加一个意向召唤。即,
DetailProductDescription 中的
watchListBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(DetailProductDescription.this, LoginForm.class);
intent.putExtra("from","watch");
startActivity(intent);
}
});
wishListBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(DetailProductDescription.this, LoginForm.class);
intent.putExtra("from","wish");
startActivity(intent);
}
});
现在,在 LoginForm
中String from=getIntent.getStringExtra("from");// you got it as 'watch' or 'wish', or null.
现在检查字符串并继续。
答案 1 :(得分:1)
最好在登录xml布局中包含WatchList按钮和WishList按钮。默认情况下,这些按钮的可见性应为View.INVISIBLE
或View.GONE
。您可以在布局中隐藏这些按钮,也可以在登录活动的onCreate
方法中隐藏这些按钮。
Button watchListBtn = null;
Button wishListBtn = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_login_screen);
watchListBtn = (Button) findViewById(R.id.loginBtn);
watchListBtn.setVisibility(View.GONE);
watchListBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(LoginForm.this, WatchList.class);
startActivity(intent);
}
});
wishListBtn = (Button) findViewById(R.id.wishlistBtn);
wishListBtn.setVisibility(View.GONE);
wishListBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// your code to launch wishlist activity
}
});
// your other onCreate stuff........
}
然后是您的登录验证码
if(isUserValidated && isPasswordValidated) {
if(DetailProductDescription.product_id==null) {
Intent intent = new Intent(LoginForm.this,HomePage.class);
startActivity(intent);
} else {
Intent intent = new Intent(LoginForm.this,WatchList.class);
startActivity(intent);
}
} else {
watchListBtn.setVisibility(View.VISIBLE);
wishListBtn.setVisibility(View.VISIBLE);
}