Example usage for android.widget ImageView findViewById

List of usage examples for android.widget ImageView findViewById

Introduction

In this page you can find the example usage for android.widget ImageView findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:codetoanalyze.java.checkers.AnnotatedInterface.java

@PerformanceCritical
View callsFindViewByIdFromView(ImageView view, int id) {
    return view.findViewById(id);
}

From source file:com.filemanager.free.adapters.DrawerAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (values.get(position).isSection()) {
        ImageView view = new ImageView(context);
        if (m.theme1 == 0)
            view.setImageResource(R.color.divider);
        else//from www  .j  a va2  s .  c  om
            view.setImageResource(R.color.divider_dark);
        view.setClickable(false);
        view.setFocusable(false);
        if (m.theme1 == 0)
            view.setBackgroundColor(Color.WHITE);
        else
            view.setBackgroundResource(R.color.background_material_dark);
        view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17)));
        view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8));
        return view;
    } else {
        View view = inflater.inflate(R.layout.drawerrow, parent, false);
        final TextView txtTitle = (TextView) view.findViewById(R.id.firstline);
        final ImageView imageView = (ImageView) view.findViewById(R.id.icon);
        if (m.theme1 == 0) {
            view.setBackgroundResource(R.drawable.safr_ripple_white);
        } else {
            view.setBackgroundResource(R.drawable.safr_ripple_black);
        }
        view.setOnClickListener(new View.OnClickListener() {

            public void onClick(View p1) {
                m.selectItem(position);
            }
            // TODO: Implement this method

        });
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (!getItem(position).isSection())
                    // not to remove the first bookmark (storage) and permanent bookmarks
                    if (position > m.storage_count && position < values.size() - 7) {
                        EntryItem item = (EntryItem) getItem(position);
                        String path = (item).getPath();
                        if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) {
                            m.renameBookmark((item).getTitle(), path);
                        } else if (path.startsWith("smb:/")) {
                            m.showSMBDialog(item.getTitle(), path, true);
                        }
                    } else if (position < m.storage_count) {
                        String path = ((EntryItem) getItem(position)).getPath();
                        if (!path.equals("/"))
                            new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m,
                                    m.theme1);
                    }

                // return true to denote no further processing
                return true;
            }
        });

        txtTitle.setText(((EntryItem) (values.get(position))).getTitle());
        imageView.setImageDrawable(getDrawable(position));
        imageView.clearColorFilter();
        if (myChecked.get(position)) {
            if (m.theme1 == 0)
                view.setBackgroundColor(Color.parseColor("#ffeeeeee"));
            else
                view.setBackgroundColor(Color.parseColor("#ff424242"));
            imageView.setColorFilter(fabskin);
            txtTitle.setTextColor(Color.parseColor(m.fabskin));
        } else {
            if (m.theme1 == 0) {
                imageView.setColorFilter(Color.parseColor("#666666"));
                txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black));
            } else {
                imageView.setColorFilter(Color.WHITE);
                txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
            }
        }

        return view;
    }
}