Search in sources :

Example 26 with CheckedTextView

use of android.widget.CheckedTextView in project apps-android-commons by commons-app.

the class CategorizationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_categorization, null);
    categoriesList = (ListView) rootView.findViewById(R.id.categoriesListBox);
    categoriesFilter = (EditText) rootView.findViewById(R.id.categoriesSearchBox);
    categoriesSearchInProgress = (ProgressBar) rootView.findViewById(R.id.categoriesSearchInProgress);
    categoriesNotFoundView = (TextView) rootView.findViewById(R.id.categoriesNotFound);
    categoriesSkip = (TextView) rootView.findViewById(R.id.categoriesExplanation);
    categoriesSkip.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getActivity().onBackPressed();
            getActivity().finish();
        }
    });
    ArrayList<CategoryItem> items;
    if (savedInstanceState == null) {
        items = new ArrayList<>();
        categoriesCache = new HashMap<>();
    } else {
        items = savedInstanceState.getParcelableArrayList("currentCategories");
        categoriesCache = (HashMap<String, ArrayList<String>>) savedInstanceState.getSerializable("categoriesCache");
    }
    categoriesAdapter = new CategoriesAdapter(getActivity(), items);
    categoriesList.setAdapter(categoriesAdapter);
    categoriesList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int index, long id) {
            CheckedTextView checkedView = (CheckedTextView) view;
            CategoryItem item = (CategoryItem) adapterView.getAdapter().getItem(index);
            item.selected = !item.selected;
            checkedView.setChecked(item.selected);
            if (item.selected) {
                updateCategoryCount(item.name);
            }
        }
    });
    categoriesFilter.addTextChangedListener(textWatcher);
    startUpdatingCategoryList();
    return rootView;
}
Also used : CheckedTextView(android.widget.CheckedTextView) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView)

Aggregations

CheckedTextView (android.widget.CheckedTextView)26 View (android.view.View)17 TextView (android.widget.TextView)9 ListView (android.widget.ListView)6 AdapterView (android.widget.AdapterView)5 SuppressLint (android.annotation.SuppressLint)4 LayoutInflater (android.view.LayoutInflater)4 ArrayAdapter (android.widget.ArrayAdapter)3 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 TypedArray (android.content.res.TypedArray)2 Pair (android.util.Pair)2 ViewGroup (android.view.ViewGroup)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 SelectionOverride (com.google.android.exoplayer2.trackselection.MappingTrackSelector.SelectionOverride)2 GraphView (com.jjoe64.graphview.GraphView)2 Account (android.accounts.Account)1 Intent (android.content.Intent)1