Java Code Examples for android.widget.RelativeLayout.setOnLongClickListener()

The following are Jave code examples for showing how to use setOnLongClickListener() of the android.widget.RelativeLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DaiGo   File: ComplexButton.java   Source Code and License Vote up 6 votes
public ComplexButton(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.complex_button, this);

    button = (RelativeLayout) findViewById(R.id.complex_button_body);
    rightArrow = (ImageView) findViewById(R.id.complex_button_item_right_arrow);
    circleImageView = (CircleImageView) findViewById(R.id.complex_button_item_image);
    itemName = (TextView) findViewById(R.id.complex_button_item_name);
    detail = (TextView) findViewById(R.id.complex_button_item_detail);
    redDot = (ImageView) findViewById(R.id.complex_button_red_dot);

    redDot.setVisibility(GONE);

    setButtonClickable(true);
    button.setLongClickable(true);
    button.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            return true;
        }
    });

    selectType(TYPE_IMAGE_ROUND);
}
 
Example 2
Project: Artist   File: CanvasActivity.java   Source Code and License Vote up 5 votes
private void addColorButton(){
    for(int i=0;i<12;i++){
        FloatingActionButton floatingActionButton = new FloatingActionButton(CanvasActivity.this);
        floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(colorArr[i])));
        floatingActionButton.setCompatElevation(0);
        floatingActionButton.setTag("button");

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(108,108);
        params.setMargins(32,0,32,0);
        final RelativeLayout relativeLayout = new RelativeLayout(CanvasActivity.this);
        relativeLayout.addView(floatingActionButton, params);
        relativeLayout.setOnClickListener(this);
        if(i == 11){
            relativeLayout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    setDialog((FloatingActionButton) view.findViewWithTag("button"));
                    relativeLayout.callOnClick();
                    return true;
                }
            });
        }

        if(i > 5){
            colorSelectLayout2.addView(relativeLayout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
        }else{
            colorSelectLayout1.addView(relativeLayout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));
        }
    }
}
 
Example 3
Project: MenuSet   File: Utils.java   Source Code and License Vote up 5 votes
public static RelativeLayout getImageWrapper(Context context, MenuObject menuItem, int menuItemSize,
                                             View.OnClickListener onCLick, View.OnLongClickListener onLongClick,
                                             boolean showDivider) {
    RelativeLayout imageWrapper = new RelativeLayout(context);
    LinearLayout.LayoutParams imageWrapperLayoutParams = new LinearLayout.LayoutParams(menuItemSize, menuItemSize);
    imageWrapper.setLayoutParams(imageWrapperLayoutParams);
    imageWrapper.setOnClickListener(onCLick);
    imageWrapper.setOnLongClickListener(onLongClick);
    imageWrapper.addView(Utils.getItemImageButton(context, menuItem));
    if (showDivider) {
        imageWrapper.addView(getDivider(context, menuItem));
    }

    if (menuItem.getBgColor() != 0) {
        imageWrapper.setBackgroundColor(menuItem.getBgColor());
    } else if (menuItem.getBgDrawable() != null) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            imageWrapper.setBackgroundDrawable(menuItem.getBgDrawable());
        } else {
            imageWrapper.setBackground(menuItem.getBgDrawable());
        }
    } else if (menuItem.getBgResource() != 0) {
        imageWrapper.setBackgroundResource(menuItem.getBgResource());
    } else {
        imageWrapper.setBackgroundColor(context.getResources().getColor(R.color.menu_item_background));
    }
    return imageWrapper;
}