I enabled greying out disabled list items in the Add Feature dialog

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-24 12:23:16 -04:00
parent 0752cc1aa8
commit b5377fd841

View File

@@ -144,9 +144,9 @@ public class FeatureListFragment extends Fragment implements OnClickListener, an
public void onClick(View v) { public void onClick(View v) {
new AlertDialog.Builder(this.getActivity()) new AlertDialog.Builder(this.getActivity())
.setTitle(R.string.add_feature) .setTitle(R.string.add_feature)
// .setItems(R.array.features, this)
.setAdapter( .setAdapter(
new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_list_item_1, this.getResources().getStringArray(R.array.features)){ new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_list_item_1, this.getResources().getStringArray(R.array.features)){
/** /**
* we override this, because we want to filter which items are enabled * we override this, because we want to filter which items are enabled
* (non-Javadoc) * (non-Javadoc)
@@ -157,6 +157,18 @@ public class FeatureListFragment extends Fragment implements OnClickListener, an
return false; return false;
} }
/**
* here we want to grey out disabled items in the list
* (non-Javadoc)
* @see android.widget.ArrayAdapter#getView(int, android.view.View, android.view.ViewGroup)
*/
@Override
public View getView(int position, View convertView, ViewGroup parent){
final View v = super.getView(position, convertView, parent);
v.setEnabled(isEnabled(position));
return v;
}
/** /**
* here we can notify the adaptor if an item should be enabled or not * here we can notify the adaptor if an item should be enabled or not
* (non-Javadoc) * (non-Javadoc)
@@ -167,7 +179,6 @@ public class FeatureListFragment extends Fragment implements OnClickListener, an
return ! mAdded.contains(position); return ! mAdded.contains(position);
} }
}, this) }, this)
.create()
.show(); .show();
} }