当前位置: 首页>>代码示例>>Java>>正文


Java View.setOnClickListener方法代码示例

本文整理汇总了Java中android.view.View.setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.setOnClickListener方法的具体用法?Java View.setOnClickListener怎么用?Java View.setOnClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setOnClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureHeader

import android.view.View; //导入方法依赖的package包/类
/**
 * Get a header view. This optionally pulls a header from the supplied
 * {@link WrapperView} and will also recycle the divider if it exists.
 */
private View configureHeader(WrapperView wv, final int position) {
	View header = wv.mHeader == null ? popHeader() : wv.mHeader;
	header = mDelegate.getHeaderView(position, header, wv);
	if (header == null) {
		throw new NullPointerException("Header view must not be null.");
	}
	//if the header isn't clickable, the listselector will be drawn on top of the header
	header.setClickable(true);
	header.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			if(mOnHeaderClickListener != null){
				long headerId = mDelegate.getHeaderId(position);
				mOnHeaderClickListener.onHeaderClick(v, position, headerId);
			}
		}
	});
	return header;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:25,代码来源:AdapterWrapper.java

示例2: setupDrawerLayout

import android.view.View; //导入方法依赖的package包/类
/**
 * Initialize the drawer.
 */
private void setupDrawerLayout() {
    drawerLayout = findViewById(R.id.drawer_layout);
    NavigationView navigationView = findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);
    header.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.closeDrawers();
        }
    });

    final Toolbar toolbar = findViewById(R.id.toolbar);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(
            this,  drawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );
    drawerLayout.addDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:24,代码来源:MainActivity.java

示例3: setTrashIcon

import android.view.View; //导入方法依赖的package包/类
/**
 * @param trashIcon The view for toggling the trash.
 */
public void setTrashIcon(View trashIcon) {
    if (trashIcon == null) {
        return;
    }
    // The trash icon is always a drop target.
    trashIcon.setOnDragListener(new OnDragToTrashListener(mController));
    if (mTrashUi != null && mTrashIsCloseable) {
        // But we only need a click listener if the trash can be closed.
        trashIcon.setOnClickListener(mTrashClickListener);
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:15,代码来源:FlyoutController.java

示例4: DrawerMenuItemViewHolder

import android.view.View; //导入方法依赖的package包/类
public DrawerMenuItemViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    mSwitchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> onClick());
    itemView.setOnClickListener(v -> {
        if (mSwitchCompat.getVisibility() == VISIBLE) {
            mSwitchCompat.toggle();
        } else {
            onClick();
        }
    });
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:13,代码来源:DrawerMenuItemViewHolder.java

示例5: UserRuleHolder

import android.view.View; //导入方法依赖的package包/类
public UserRuleHolder(NotificationRulesAdapter adapter, View itemView) {
    super(adapter, itemView);
    itemView.setOnClickListener((View view) -> {
        Intent intent = new Intent(view.getContext(), EditNotificationSettingsActivity.class);
        intent.putExtra(EditNotificationSettingsActivity.ARG_USER_RULE_INDEX, getAdapterPosition() - adapter.getUserRulesStartIndex());
        view.getContext().startActivity(intent);
    });
    itemView.findViewById(R.id.reorder).setOnTouchListener((View v, MotionEvent e) -> {
        if (e.getActionMasked() == MotionEvent.ACTION_DOWN)
            adapter.mItemTouchHelper.startDrag(UserRuleHolder.this);
        return false;
    });
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:14,代码来源:NotificationRulesAdapter.java

示例6: onCreateViewHolder

import android.view.View; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycler_item, null);
    ItemHolder itemHolder = new ItemHolder(view);
    view.setOnClickListener(this);
    return itemHolder;
}
 
开发者ID:gaelthas,项目名称:Pindroid,代码行数:8,代码来源:ItemAdapter.java

示例7: ItemHolder

import android.view.View; //导入方法依赖的package包/类
public ItemHolder(View view) {
    super(view);
    this.title = (TextView) view.findViewById(R.id.song_title);
    this.artist = (TextView) view.findViewById(R.id.song_artist);
    this.albumArt = (ImageView) view.findViewById(R.id.albumArt);
    this.popupMenu = (ImageView) view.findViewById(R.id.popup_menu);
    visualizer = (MusicVisualizer) view.findViewById(R.id.visualizer);
    view.setOnClickListener(this);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:10,代码来源:BaseQueueAdapter.java

示例8: ViewHolder

import android.view.View; //导入方法依赖的package包/类
public ViewHolder(View itemView) {
    super(itemView);
    progressBar = (ProgressBar) itemView.findViewById(R.id.pb_loading);
    tips = (TextView) itemView.findViewById(R.id.tv_tips);
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (data.getState() == LoadMoreItem.STATE_FAILED && mRetryListener != null) {
                mRetryListener.onRetry();
                data.setState(LoadMoreItem.STATE_LOADING);
                updateView(LoadMoreItem.STATE_LOADING);
            }
        }
    });
}
 
开发者ID:yangjiantao,项目名称:AndroidUiKit,代码行数:16,代码来源:LoadMoreItemViewBinder.java

示例9: getDocumentView

import android.view.View; //导入方法依赖的package包/类
private View getDocumentView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_connection_list, parent, false);
    }

    final Cursor cursor = getItem(position);

    NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final View iconMimeBackground = convertView.findViewById(R.id.icon_mime_background);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final ImageView icon1 = (ImageView) convertView.findViewById(android.R.id.icon1);
    final TextView summary = (TextView) convertView.findViewById(android.R.id.summary);
    final View popupButton = convertView.findViewById(R.id.button_popup);
    popupButton.setVisibility(isTelevision() ? View.INVISIBLE : View.VISIBLE);

    popupButton.setOnClickListener(mListener);
    title.setText(networkConnection.getName());
    summary.setText(networkConnection.getSummary());

    iconMimeBackground.setVisibility(View.VISIBLE);
    iconMimeBackground.setBackgroundColor(
            IconColorUtils.loadSchmeColor(context, networkConnection.getType()));
    iconMime.setImageDrawable(IconUtils.loadSchemeIcon(context, networkConnection.type));
            //ContextCompat.getDrawable(context, R.drawable.ic_connection_network));
    return convertView;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:32,代码来源:ConnectionsAdapter.java

示例10: setBtnPanelView

import android.view.View; //导入方法依赖的package包/类
public BaseDialog setBtnPanelView(int layoutId, OnClickListener listener) {
        ViewGroup viewGroup = (ViewGroup) getLayoutInflater().inflate(layoutId, null, false);
        int count = viewGroup.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof Button) {
                child.setOnClickListener(this);
            }
        }
        mListener = listener;
        mBtnPanel.addView(viewGroup);
//        设置容器的背景  可以根据实际情况动态添加
//        mContainer.setBackgroundResource(R.drawable.zhenai_library_dialog_base_top_shape);
        return this;
    }
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:16,代码来源:BaseDialog.java

示例11: VideoViewHolder

import android.view.View; //导入方法依赖的package包/类
public VideoViewHolder(View itemView) {
    super(itemView);
    playerView = (VideoPlayerView) itemView.findViewById(R.id.exo_play_context_id);
    userPlayer = new ManualPlayer((Activity) mContext, playerView);
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onItemClickListener.onItemClick(getAdapterPosition());
        }
    });
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:12,代码来源:VideoAdapter.java

示例12: bindOnClickLister

import android.view.View; //导入方法依赖的package包/类
public void bindOnClickLister(View rootView, View.OnClickListener listener, @IdRes int... ids) {
    for (int id : ids) {
        View view = rootView.findViewById(id);
        if (view != null) {
            view.setOnClickListener(listener);
        }
    }
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:9,代码来源:BaseActivity.java

示例13: onCreate

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.placehold);

    View chooseButton = findViewById(R.id.choosedate_button);
    chooseButton.setOnClickListener(this);

    //Arrays for days to fill spinners
    ampm[0] = "AM";
    ampm[1] = "PM";
    Spinner daySpinner = (Spinner) findViewById(R.id.day_spinner);
    Spinner spinner = (Spinner) findViewById(R.id.month_spinner);

    for(int i=0;i<thirtyOneDays.length;i++){
        thirtyOneDays[i]=Integer.toString(1+i);
    }
    for(int i=0;i<twentyEightDays.length;i++){
        twentyEightDays[i]=Integer.toString(1+i);
    }
    for(int i=0;i<twentyNineDays.length;i++){
        twentyNineDays[i]=Integer.toString(1+i);
    }
    for(int i=0;i<thirtyDays.length;i++){
        thirtyDays[i]=Integer.toString(1+i);
    }
    for(int i=0;i<hours.length;i++){
        hours[i]=Integer.toString(1+i) + ":00";
    }

    //Month Spinner
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.month, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    String selected = spinner.getSelectedItem().toString();

    //System.out.println("selected: "+selected);
    spinner.setOnItemSelectedListener(this);

    //Day Spinner
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> dayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, thirtyOneDays);
    // Specify the layout to use when the list of choices appears
    dayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    daySpinner.setAdapter(dayAdapter);

    //Year Spinner
    Spinner yearSpinner = (Spinner) findViewById(R.id.year_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> yearAdapter = ArrayAdapter.createFromResource(this,
            R.array.years, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    yearSpinner.setAdapter(yearAdapter);
    yearSpinner.setOnItemSelectedListener(this);

    //Hour Spinner
    Spinner hourSpinner = (Spinner) findViewById(R.id.hour_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> hourAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, hours);
    // Specify the layout to use when the list of choices appears
    hourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    hourSpinner.setAdapter(hourAdapter);

    //ampm Spinner
    Spinner ampmSpinner = (Spinner) findViewById(R.id.ampm_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> ampmAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ampm);
    // Specify the layout to use when the list of choices appears
    ampmAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    ampmSpinner.setAdapter(ampmAdapter);

}
 
开发者ID:Mikerr1111,项目名称:Library-System-Android,代码行数:82,代码来源:PlaceHold.java

示例14: ForecastAdapterViewHolder

import android.view.View; //导入方法依赖的package包/类
public ForecastAdapterViewHolder(View view) {
    super(view);
    mWeatherTextView = (TextView) view.findViewById(R.id.tv_weather_data);
    // COMPLETED (7) Call setOnClickListener on the view passed into the constructor (use 'this' as the OnClickListener)
    view.setOnClickListener(this);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:7,代码来源:ForecastAdapter.java

示例15: onCreate

import android.view.View; //导入方法依赖的package包/类
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_preview);
        mContext = this;
        surfaceView = (SurfaceView) findViewById(R.id.video_preview);

        //隐藏掉Seekbar
//        surfaceView.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//                if (mediaController == null) return false;
//                if (mediaController.isShowing()) {
//                    mediaController.hide();
//                    showButtonPanel(true);
//                } else {
//                    showButtonPanel(false);
//                    mediaController.show();
//                }
//                return false;
//            }
//        });

        videoPreviewContainer = (AspectFrameLayout) findViewById(R.id.previewAspectFrameLayout);
        photoPreviewContainer = (FrameLayout) findViewById(R.id.photo_preview_container);
        imagePreview = (UCropView) findViewById(R.id.image_view);
        buttonPanel = (ViewGroup) findViewById(R.id.preview_control_panel);
        View confirmMediaResult = findViewById(R.id.confirm_media_result);
        View reTakeMedia = findViewById(R.id.re_take_media);
        View cancelMediaAction = findViewById(R.id.cancel_media_action);

        findViewById(R.id.crop_image).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                UCrop.Options options = new UCrop.Options();
                options.setToolbarColor(ContextCompat.getColor(mContext, android.R.color.black));
                options.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.black));
                Uri uri = Uri.fromFile(new File(previewFilePath));
                UCrop.of(uri, uri)
                        .withOptions(options)
                        .start(mContext);
            }
        });

        if (confirmMediaResult != null)
            confirmMediaResult.setOnClickListener(this);

        if (reTakeMedia != null)
            reTakeMedia.setOnClickListener(this);

        if (cancelMediaAction != null)
            cancelMediaAction.setOnClickListener(this);

        Bundle args = getIntent().getExtras();

        mediaAction = args.getInt(MEDIA_ACTION_ARG);
        previewFilePath = args.getString(FILE_PATH_ARG);
        showCrop = args.getBoolean(SHOW_CROP);

        if (mediaAction == CameraConfiguration.MEDIA_ACTION_VIDEO) {
            displayVideo(savedInstanceState);
        } else if (mediaAction == CameraConfiguration.MEDIA_ACTION_PHOTO) {
            displayImage();
        } else {
            String mimeType = Utils.getMimeType(previewFilePath);
            if (mimeType.contains(MIME_TYPE_VIDEO)) {
                displayVideo(savedInstanceState);
            } else if (mimeType.contains(MIME_TYPE_IMAGE)) {
                displayImage();
            } else finish();
        }
    }
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:73,代码来源:PreviewActivity.java


注:本文中的android.view.View.setOnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。