提前建议我
问题域
当我再次CLick这两个项目将在listview中再添加一次,但我不需要这个重复
tvInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvInfo.setBackgroundResource(R.drawable.company_left_btn);
tvCompanies.setBackgroundResource(R.drawable.info_right_btn);
llDriverDetails.setVisibility(View.VISIBLE);
llCompaniesDetails.setVisibility(View.GONE);
list.add("Big Truck Little Comp");
list.add("Mani Info Tech");
}
});
答案 0 :(得分:0)
许多建议很容易就是disable
按钮`
tvInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvInfo.setBackgroundResource(R.drawable.company_left_btn);
tvCompanies.setBackgroundResource(R.drawable.info_right_btn);
llDriverDetails.setVisibility(View.VISIBLE);
llCompaniesDetails.setVisibility(View.GONE);
list.add("Big Truck Little Comp");
list.add("Mani Info Tech");
// Disableling Button
tvInfo.setEnabled(false);
}
});`
答案 1 :(得分:0)
这样做,
boolean flag=true;
tvInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvInfo.setBackgroundResource(R.drawable.company_left_btn);
tvCompanies.setBackgroundResource(R.drawable.info_right_btn);
llDriverDetails.setVisibility(View.VISIBLE);
llCompaniesDetails.setVisibility(View.GONE);
if(flag)
{
list.add("Big Truck Little Comp");
list.add("Mani Info Tech");
flag=false;
}
}
});
如果您有任何反馈,请与我们联系。