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


Java View类代码示例

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


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

示例1: initViews

import android.view.View; //导入依赖的package包/类
private void initViews() {

        list = (RecyclerView) findViewById(R.id.rmp_a_list);

        adapter = new RMPAdapter(this, data);
        list.setLayoutManager(new LinearLayoutManager(this));

        line = findViewById(R.id.rmp_a_line);
        title = (TextView) findViewById(R.id.rmp_a_title);
        toolbar = (Toolbar) findViewById(R.id.rmp_a_toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        first = new FirstThreeViewHolder(this, FirstThreeViewHolder.FIRST);
        second = new FirstThreeViewHolder(this, FirstThreeViewHolder.SECOND);
        third = new FirstThreeViewHolder(this, FirstThreeViewHolder.THIRD);
        first.setVisible(View.INVISIBLE);
        second.setVisible(View.INVISIBLE);
        third.setVisible(View.INVISIBLE);

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:22,代码来源:RecentMostPlayActivity.java

示例2: onChanged

import android.view.View; //导入依赖的package包/类
@Override
public void onChanged() {
    Adapter<?> adapter = getAdapter();
    if (adapter != null && mEmptyView != null) {
        int emptyCount = 0;
        if (pullRefreshEnabled) {
            emptyCount++;
        }
        if (loadMoreEnabled) {
            emptyCount++;
        }
        if (adapter.getItemCount() == emptyCount) {
            mEmptyView.setVisibility(View.VISIBLE);
            YRecycleview.this.setVisibility(View.GONE);
        } else {
            mEmptyView.setVisibility(View.GONE);
            YRecycleview.this.setVisibility(View.VISIBLE);
        }
    }
    if (mWrapAdapter != null) {
        mWrapAdapter.notifyDataSetChanged();
    }
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:24,代码来源:YRecycleview.java

示例3: onBindViewHolder

import android.view.View; //导入依赖的package包/类
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
    final Ornament bean = mData.get(position);
    if (bean != null) {
        holder.ivImg.setColorFilter(Color.WHITE);
        holder.ivImg.setImageResource(bean.getImgResId());

        holder.ivImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(position);
                }
            }
        });
    } else {
        holder.ivImg.setImageResource(0);
    }
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:20,代码来源:OrnamentAdapter.java

示例4: onBindData2View

import android.view.View; //导入依赖的package包/类
@Override
public void onBindData2View(final StoriesBean data) {
    desc.setText(data.getTitle());
    if (data.getImages() != null
            && data.getImages().size() > 0) {
        avatar.setVisibility(View.VISIBLE);
        loadAvatar(data.getImages().get(0), avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
    hotContentView.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Context context = v.getContext();
                    Intent intent = new Intent(context, ArticleDetailActivity.class);
                    intent.putExtra(EXTRA_ARTICLE_ID, data.getId());
                    intent.putExtra(EXTRA_ARTICLE_TYPE, EXTRA_TYPE_ZHIHU_NEWS);
                    context.startActivity(intent);
                }
            });
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:23,代码来源:SpecialListAdapter.java

示例5: onClick

import android.view.View; //导入依赖的package包/类
@OnClick(R.id.fab)
    public void onClick() {
        if (!isConnected()){
            TipUtil.showSnackbar(mCoordinatorLayout, getString(R.string.hint_disconnect), getString(R.string.connect), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    connect();
                }
            });
            return;
        }

        if (mCurrentMode == SUBSCRIPTION) {
//            startActivityForResult(SubscriptionActivity.class, SUBSCRIPTION);
            SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
            subscriptionFragment.show(getSupportFragmentManager(), "Subscription");
        } else if (mCurrentMode == PUBLICATION) {
            startActivityForResult(PublicationActivity.class, PUBLICATION);
        }


    }
 
开发者ID:emqtt,项目名称:EMQ-Android-Toolkit,代码行数:23,代码来源:DashboardActivity.java

示例6: onLongClick

import android.view.View; //导入依赖的package包/类
@Override
public boolean onLongClick(View v) {
    if (v == mCloseButton) {
        return showAccessibilityToast(v, getResources().getString(R.string.close_tab));
    } else if (v == mCustomActionButton) {
        return showAccessibilityToast(v, mCustomActionButton.getContentDescription());
    } else if (v == mTitleUrlContainer) {
        ClipboardManager clipboard = (ClipboardManager) getContext()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        Tab tab = getCurrentTab();
        if (tab == null) return false;
        String url = tab.getOriginalUrl();
        ClipData clip = ClipData.newPlainText("url", url);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(getContext(), R.string.url_copied, Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:CustomTabToolbar.java

示例7: showAtAnchorView

import android.view.View; //导入依赖的package包/类
/**
 * 相对anchor view显示,适用 宽高不为match_parent
 * <p>
 * 注意:如果使用 VerticalGravity 和 HorizontalGravity 时,请确保使用之后 PopupWindow 没有超出屏幕边界,
 * 如果超出屏幕边界,VerticalGravity 和 HorizontalGravity 可能无效,从而达不到你想要的效果。
 *
 * @param anchor
 * @param vertGravity  垂直方向的对齐方式
 * @param horizGravity 水平方向的对齐方式
 * @param x            水平方向的偏移
 * @param y            垂直方向的偏移
 */
public void showAtAnchorView(@NonNull View anchor, @VerticalGravity final int vertGravity, @HorizontalGravity int horizGravity, int x, int y) {
    if (mPopupWindow == null) {
        return;
    }
    mAnchorView = anchor;
    mOffsetX = x;
    mOffsetY = y;
    mVerticalGravity = vertGravity;
    mHorizontalGravity = horizGravity;
    isOnlyGetWH = false;
    //处理背景变暗
    handleBackgroundDim();
    final View contentView = getContentView();
    addGlobalLayoutListener(contentView);
    contentView.measure(0, View.MeasureSpec.UNSPECIFIED);
    final int measuredW = contentView.getMeasuredWidth();
    final int measuredH = contentView.getMeasuredHeight();

    x = calculateX(anchor, horizGravity, measuredW, x);
    y = calculateY(anchor, vertGravity, measuredH, y);
    Log.i(TAG, "showAtAnchorView: w=" + measuredW + ",y=" + measuredH);
    PopupWindowCompat.showAsDropDown(mPopupWindow, anchor, x, y, Gravity.NO_GRAVITY);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:EasyPopup.java

示例8: initTopBar

import android.view.View; //导入依赖的package包/类
private void initTopBar() {
    mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popBackStack();
        }
    });

    // 切换其他情况的按钮
    mTopBar.addRightImageButton(R.mipmap.icon_topbar_overflow, R.id.topbar_right_change_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showBottomSheetList();
        }
    });

    mTopBar.setTitle(mQDItemDescription.getName());
}
 
开发者ID:coopese,项目名称:qmui,代码行数:19,代码来源:QDEmptyViewFragment.java

示例9: initEvent

import android.view.View; //导入依赖的package包/类
@Override
public void initEvent() {//必须调用
	super.initEvent();

	lvBaseList.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			toActivity(UserActivity.createIntent(context, id));
		}
	});
}
 
开发者ID:TommyLemon,项目名称:APIJSON-Android-RxJava,代码行数:13,代码来源:UserListFragment.java

示例10: initBlackListStatusView

import android.view.View; //导入依赖的package包/类
private void initBlackListStatusView() {
    if (mIsFriendsRelationship) {
        Button rightButton = getHeadRightButton();
        rightButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.main_activity_contact_more));
        rightButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                RongIM.getInstance().getBlacklistStatus(mFriend.getUserId(), new RongIMClient.ResultCallback<RongIMClient.BlacklistStatus>() {
                    @Override
                    public void onSuccess(RongIMClient.BlacklistStatus blacklistStatus) {
                        SinglePopWindow morePopWindow = new SinglePopWindow(UserDetailActivity.this, mFriend, blacklistStatus);
                        morePopWindow.showPopupWindow(v);
                    }

                    @Override
                    public void onError(RongIMClient.ErrorCode e) {

                    }
                });
            }
        });
    }
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:24,代码来源:UserDetailActivity.java

示例11: onCreate

import android.view.View; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photo);
    ButterKnife.bind(this);
    setupActionBar(toolbar, "", true);
    final String url = getIntent().getStringExtra("imgUrl");
    with(this).load(url).into(mPhotoView);
    mPhotoView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            savePic(url);
            return true;
        }
    });
}
 
开发者ID:shenhuanet,项目名称:ZhidaoDaily-android,代码行数:17,代码来源:PhotoActivity.java

示例12: onKeyEvent

import android.view.View; //导入依赖的package包/类
public boolean onKeyEvent(int keyCode, KeyEvent event) {
	try {
		int resId = ResHelper.getIdRes(activity, "llSearch");
		if (keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN
				&& activity.findViewById(resId).getVisibility() == View.VISIBLE) {
			activity.findViewById(resId).setVisibility(View.GONE);
			resId = ResHelper.getIdRes(activity, "llTitle");
			activity.findViewById(resId).setVisibility(View.VISIBLE);
			etSearch.setText("");
			return true;
		}
	} catch (Exception e) {
		SMSLog.getInstance().w(e);
	}
	return super.onKeyEvent(keyCode, event);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ContactsPage.java

示例13: onVideoItemChangeToFullScreenClick

import android.view.View; //导入依赖的package包/类
@Override
public void onVideoItemChangeToFullScreenClick(EssayAdapter.VideoViewHolder videoViewHolder) {
    // 这里这个ViewGroup 是Window的
    final ViewGroup vp = (ViewGroup)(findViewById(Window.ID_ANDROID_CONTENT));

    videoViewHolder.basicVideoView.setPlayer(null);

    final BasicVideoView newBasicVideoView = (BasicVideoView) View.inflate(this, R.layout.basic_videoview, null);
    newBasicVideoView.setPlayer(mPlayer);
    View changeToInsetScreen = newBasicVideoView.findViewById(R.id.changeToInsetScreen);
    changeToInsetScreen.setOnClickListener(this);

    final FrameLayout.LayoutParams lpParent = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    final FrameLayout frameLayout = new FrameLayout(this);
    frameLayout.setId(R.id.full_screen_id);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lp.gravity = Gravity.CENTER;
    frameLayout.addView(newBasicVideoView, lp);
    vp.addView(frameLayout, lpParent);
    mPlayer.seekTo(mPlayer.getCurrentPosition() - 20);
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:23,代码来源:EssayDetailActivity.java

示例14: initViews

import android.view.View; //导入依赖的package包/类
protected void initViews() {
    this.mVideoView = (ExVideoView) findViewById(R.id.video);
    this.mHeaderView = findViewById(R.id.header);
    this.mBtnBack = findViewById(R.id.btn_back);
    this.mVideoView.setExpandState(true);
    this.mVideoView.setStatus(2);
    this.mVideoView.setContinueVideo(this.mUri);
    this.mVideoView.getVideoView().setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {
            SportPlayActivity.this.setResult(-1);
            SportPlayActivity.this.finish();
        }
    });
    this.mVideoView.getControllerView().addBindView(this.mHeaderView);
    this.mBtnBack.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            SportPlayActivity.this.onBackPressed();
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:SportPlayActivity.java

示例15: onWidgetClick

import android.view.View; //导入依赖的package包/类
@Override
public void onWidgetClick(View view) {
    tvAboutFragment.setText("");
    switch (view.getId()) {
        case R.id.btn_show_about_fragment:
            tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
                    + "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
                    + "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\n---all of fragments---\n"
                    + FragmentUtils.getAllFragments(getFragmentManager()).toString()
                    + "\n----------------------\n\n"
                    + "---stack top---\n"
                    + FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
                    + "\n---stack bottom---\n\n"
            );
            break;
        case R.id.btn_hide_show:
            FragmentUtils.hideAllShowFragment(((FragmentActivity) getActivity()).rootFragment);
            break;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Demo1Fragment.java


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