我是 android 新手,希望得到您的帮助。
我在一个活动中有五个按钮。每个按钮通向不同的活动。单击每个按钮时,我们将进入一个活动,在该活动中我执行数据库插入功能,而在返回用户时,我们将进入保留五个按钮的主要活动。
现在,我想要的是我希望用户知道他已经点击了哪个按钮,以避免用户的困惑。那就是我想在他完成每个按钮所引导的活动中的插入后禁用该按钮。
这是我尝试过的:
public class ResourcesActivity extends Activity {
static boolean isBtnVenueClikced = false; {
public void buttonListeners() {
venue_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
isBtnVenueClikced = true;
Log.i("In button venue click isBtnVenueClikced ", isBtnVenueClikced + "");
Intent venue_intent = new Intent(getApplicationContext(), VenueActivity.class);
venue_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(venue_intent);
}
});
food_cost_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("In Food Button isBtnVenueClikced ", isBtnVenueClikced + "");
//isBtnFoodClicked = true;
Intent food_intent = new Intent(getApplicationContext(), FoodAndBeveragesActivity.class);
food_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(food_intent);
}
});
accomodation_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//isBtnAccClicked = true;
Intent accomodation_intent = new Intent(getApplicationContext(), AccomodationActivity.class);
accomodation_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(accomodation_intent);
}
});
guest_details_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//isBtnGuestClicked = true;
Intent guest_details_intent = new Intent(getApplicationContext(), GuestDetailsActivity.class);
guest_details_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(guest_details_intent);
}
});
miscl_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//isBtnOtheClicked = true;
Intent others_intent = new Intent(getApplicationContext(), OthersActivity.class);
others_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(others_intent);
}
});
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.i("In onResume isBtnVenueClikced ", isBtnVenueClikced + "");
//checkcliks();
//isBtnVenueClikced = false;
if (isBtnVenueClikced == false) {
venue_btn.setEnabled(true);
} else {
venue_btn.setEnabled(false);
}
}
}