Java Code Examples for android.view.ViewGroup#setClickable()

The following examples show how to use android.view.ViewGroup#setClickable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WidgetConfigActivity.java    From homeassist with Apache License 2.0 6 votes vote down vote up
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = View.inflate(getContext(), R.layout.item_widget_select, null);
    }

    Entity entity = items.get(position);

    ViewGroup mItemView = convertView.findViewById(R.id.item);
    TextView mIconView = convertView.findViewById(R.id.text_mdi);
    TextView mMainText = convertView.findViewById(R.id.main_text);
    TextView mLabelText = convertView.findViewById(R.id.sub_text);

    mIconView.setText(entity.getMdiIcon());

    mItemView.setClickable(false);
    mItemView.setFocusable(false);
    mMainText.setText(entity.attributes.friendlyName);
    mLabelText.setText(entity.getDomain());

    //((TextView) convertView).setText(allItems.get(position).colour);
    return convertView;
}
 
Example 2
Source File: MainDragLayout.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
        super.onFinishInflate();
        menu = (ViewGroup) getChildAt(0);
        View view = getChildAt(getChildCount() - 1);
        if (view instanceof ContentView) {
                content = (ContentView) view;
                LogUtil.e("range" + range);
                LogUtil.e("range1" + getWidth() * 0.8);
                content.setRange((int) (getWidth() * 0.8));
        }
        if (SHADOW) {
                ivShadow = new ImageView(getContext());
                LogUtil.e("这里执行了吗");
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
                addView(ivShadow, 1, layoutParams);
        }
        menu.setClickable(true);
        content.setClickable(true);
}
 
Example 3
Source File: DragLayout.java    From TestChat with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
        super.onFinishInflate();
        menu = (ViewGroup) getChildAt(0);
        View view = getChildAt(getChildCount() - 1);
        if (view instanceof ContentView) {
                content = (ContentView) view;
                LogUtil.e("range" + range);
                LogUtil.e("range1" + getWidth() * 0.8);
                content.setRange((int) (getWidth() * 0.8));
        }
        if (SHADOW) {
                ivShadow = new ImageView(getContext());
                LogUtil.e("这里执行了吗");
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
                ivShadow.setImageResource(R.drawable.shadow);
                addView(ivShadow, 1, layoutParams);
        }
        menu.setClickable(true);
        content.setClickable(true);
}
 
Example 4
Source File: EditActivity.java    From homeassist with Apache License 2.0 4 votes vote down vote up
private void showAddDialog() {
    if (mEntities == null) mEntities = DatabaseManager.getInstance(this).getEntities();

    Collections.sort(mEntities, new Comparator<Entity>() {
        @Override
        public int compare(Entity lhs, Entity rhs) {
            return lhs.getFriendlyName().compareTo(rhs.getFriendlyName()); //descending order
        }
    });

    final ArrayAdapter<Entity> adapter = new ArrayAdapter<Entity>(this, android.R.layout.simple_list_item_1, mEntities) {
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(getContext(), R.layout.item_widget_select, null);
            }

            Entity entity = mEntities.get(position);

            ViewGroup mItemView = convertView.findViewById(R.id.item);
            TextView mIconView = convertView.findViewById(R.id.text_mdi);
            TextView mMainText = convertView.findViewById(R.id.main_text);
            TextView mLabelText = convertView.findViewById(R.id.sub_text);

            ProgressBar mProgressBar = convertView.findViewById(R.id.progressbar);

            mItemView.setClickable(false);
            mItemView.setFocusable(false);
            mIconView.setText(entity.getMdiIcon());
            mMainText.setText(entity.attributes.friendlyName);
            mLabelText.setText(entity.getDomain());
            mProgressBar.setVisibility(View.GONE);
            return convertView;
        }
    };


    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.title_additem);
    builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            mEdited = true;
            Entity selectedEntity = mEntities.get(which);
            mItems.add(selectedEntity);
            mAdapter.notifyItemInserted(mItems.size() - 1);

        }
    });
    builder.show();
}
 
Example 5
Source File: GroupActivity.java    From homeassist with Apache License 2.0 4 votes vote down vote up
private void showAddDialog() {
    if (mEntities == null) mEntities = DatabaseManager.getInstance(this).getEntities();

    Collections.sort(mEntities, new Comparator<Entity>() {
        @Override
        public int compare(Entity lhs, Entity rhs) {
            //Log.d("YouQi", "rhs: " + CommonUtil.deflate(rhs));
            //Log.d("YouQi", "lhs: " + CommonUtil.deflate(lhs));
            return lhs.getFriendlyName().compareTo(rhs.getFriendlyName()); //descending order
        }
    });

    final ArrayAdapter<Entity> adapter = new ArrayAdapter<Entity>(this, android.R.layout.simple_list_item_1, mEntities) {
        @NonNull
        @Override
        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(getContext(), R.layout.item_setting, null);
            }

            Entity entity = mEntities.get(position);

            ViewGroup mItemView = convertView.findViewById(R.id.item);
            TextView mMainText = convertView.findViewById(R.id.main_text);
            TextView mLabelText = convertView.findViewById(R.id.sub_text);
            ImageView mIconView = convertView.findViewById(R.id.image_icon);
            ProgressBar mProgressBar = convertView.findViewById(R.id.progressbar);

            mItemView.setClickable(false);
            mItemView.setFocusable(false);
            mIconView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_settings_remote_black_24dp, null));
            mMainText.setText(entity.attributes.friendlyName);
            mLabelText.setText(entity.getDomain());
            mProgressBar.setVisibility(View.GONE);

            //((TextView) convertView).setText(allItems.get(position).colour);
            return convertView;
        }
    };


    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.title_additem);
    builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            mEdited = true;
            Entity selectedEntity = mEntities.get(which);
            mItems.add(selectedEntity);
            mAdapter.notifyItemInserted(mItems.size() - 1);

        }
    });
    builder.show();
}