I have one listview that contain a text view and a checkbox in lines. I want to show custom actionbar when checkbox checked in listview. I wrote the one xml file type of menu like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://ift.tt/nIICcg" >
<item
android:id="@+id/delete"
android:title="actionbar"
android:icon="@drawable/recycle"/>
</menu>
So I use for custom listview this codes:
private class Adapter_collection extends ArrayAdapter<String> {
public Adapter_collection(Context context, int resource, int textViewResourceId,
String[] name_collection_tbl_collection) {
super(context, resource, textViewResourceId, name_collection_tbl_collection);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.listview_items, parent, false);
TextView txt_item_list_collection = (TextView)row.findViewById(R.id.textView_Item_Listview);
CheckBox checkBox=(CheckBox)row.findViewById(R.id.checkBox_Item_Listview);
checkBox.setTag(position);
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked ) {
//list_collections.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Toast.makeText(getApplicationContext(), buttonView.getTag().toString() , Toast.LENGTH_SHORT).show();
}
});
txt_item_list_collection.setText(name_collection_tbl_collection[position]);
return row;
}
}
I don't change the onCreateOptionsMenu()
Aucun commentaire:
Enregistrer un commentaire