我是android的新手。单击第一个选项卡时,我有四个按钮。我希望用户先单击第一个按钮,而不是先随机单击其他按钮。所以需要禁用其他按钮,直到我的第一个按钮被点击,一旦第一个按钮被点击,当用户返回时,所有按钮都需要被启用。我该怎么做呢?请帮忙!!
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId() == R.id.imgbtn_details)
{
attendees_imgbtn.setEnabled(true);
resources_imgbtn.setEnabled(true);
contacts_imgbtn.setEnabled(true);
count = 1;
Intent detail_intent=new Intent(getActivity().getApplicationContext(),DetailsActivity.class);
detail_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(detail_intent);
}
else if(v.getId() == R.id.imgbtn_attendees && count == 0)
{
if(count == 1)
{
Intent attendee_intent = new Intent(getActivity().getApplicationContext(),AttendeesActivity.class);
attendee_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(attendee_intent);
}
else
{
attendees_imgbtn.setEnabled(false);
resources_imgbtn.setEnabled(false);
contacts_imgbtn.setEnabled(false);
}
}
else if(v.getId() == R.id.imgbtn_resources && count == 0)
{
if(count == 1)
{
Intent resources_intent = new Intent(getActivity().getApplicationContext(),ResourcesActivity.class);
resources_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(resources_intent);
}
else
{
attendees_imgbtn.setEnabled(false);
resources_imgbtn.setEnabled(false);
contacts_imgbtn.setEnabled(false);
}
}
else if(v.getId() == R.id.imgbtn_contacts && count == 0)
{
if(count == 1)
{
Intent contact_intent = new Intent(getActivity().getApplicationContext(),ContactsActivity.class);
contact_intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(contact_intent);
}
else
{
attendees_imgbtn.setEnabled(false);
resources_imgbtn.setEnabled(false);
contacts_imgbtn.setEnabled(false);
}
}
}