本文整理匯總了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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
});
}
示例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);
}
}
示例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;
}
示例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);
}
示例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());
}
示例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));
}
});
}
示例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) {
}
});
}
});
}
}
示例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;
}
});
}
示例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);
}
示例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);
}
示例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();
}
});
}
示例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;
}
}