後,我創建具有button
和listview
的應用程序。我的問題是在此listview
中的所有項目已被點擊後啓用此button
。 Elseway button
將被禁用。在活動啓動按鈕的最後一個項目點擊
如何檢查所有項目是否已被點擊?
這裏是我的適配器請看看
public class InstallAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
public List<InstallModel> galleryItems;
ProgressDialog dia;
public InstallAdapter(Activity activity,
ArrayList<InstallModel> galleryItems) {
this.activity = activity;
this.galleryItems = galleryItems;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
Log.e("getCount :", galleryItems.size() + "");
return galleryItems.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
Log.e("getItem :", galleryItems.get(position) + "");
return galleryItems.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
Log.e("getItemId :", position + "");
return galleryItems.indexOf(getItem(position));
}
class ViewHolder {
Button Title;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final ViewHolder holder;
holder = new ViewHolder();
if (inflater == null)
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.custom_list_result, null);
Log.e("AgetView", galleryItems.size() + "");
holder.Title = (Button) convertView.findViewById(R.id.buttonInstall1);
Log.e("gallery postion", galleryItems.get(position) + "");
holder.Title.setText(galleryItems.get(position).getHeading());
holder.Title.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String url = galleryItems.get(position).getApp_url();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
activity.startActivity(i);
}
});
/*if (position == getCount() - 1) {
btGoCongrts.setEnabled(false);
} else {
btGoCongrts.setEnabled(true);
}*/
return convertView;
}
}
您需要存儲所有點擊項目的位置,並檢查每次用戶單擊listView中的項目時是否單擊了所有需要的位置。如果所有被點擊 - 啓用按鈕/ –