本文整理汇总了Java中android.widget.Button.setVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setVisibility方法的具体用法?Java Button.setVisibility怎么用?Java Button.setVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Button
的用法示例。
在下文中一共展示了Button.setVisibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerListeners
import android.widget.Button; //导入方法依赖的package包/类
private void registerListeners(View view)
{
final Button mapChooseButton = (Button) view.findViewById(R.id.mapChooseButton);
final Button mapLocateButton = (Button) view.findViewById(R.id.mapLocateButton);
final Button mapHelpButton = (Button) view.findViewById(R.id.mapHelpButton);
final Button mapZoomInButton = (Button) view.findViewById(R.id.mapZoomInButton);
final Button mapZoomOutButton = (Button) view.findViewById(R.id.mapZoomOutButton);
final Button mapLocationSearchButton = (Button) view.findViewById(R.id.mapLocationSearchButton);
if (options.isEnableControlButtons()) {
mapChooseButton.setOnClickListener(this);
mapLocateButton.setOnClickListener(this);
mapHelpButton.setOnClickListener(this);
mapZoomInButton.setOnClickListener(this);
mapZoomOutButton.setOnClickListener(this);
mapLocationSearchButton.setOnClickListener(this);
}
else {
mapChooseButton.setVisibility(View.GONE);
mapLocateButton.setVisibility(View.GONE);
mapHelpButton.setVisibility(View.GONE);
mapZoomInButton.setVisibility(View.GONE);
mapZoomOutButton.setVisibility(View.GONE);
mapLocationSearchButton.setVisibility(View.GONE);
}
}
示例2: initViews
import android.widget.Button; //导入方法依赖的package包/类
private void initViews() {
listContacts = (ListView) findViewById(R.id.chat_sdk_list_contacts);
txtSearch = (TextView) findViewById(R.id.chat_sdk_et_search);
imgSearch = (ImageView) findViewById(R.id.chat_sdk_search_image);
btnStartChat = (Button) findViewById(R.id.chat_sdk_btn_add_contacts);
chSelectAll = (CheckBox) findViewById(R.id.chat_sdk_chk_select_all);
if (mode == MODE_ADD_TO_CONVERSATION)
btnStartChat.setText(getResources().getString(R.string.add_users));
if (!BDefines.Options.GroupEnabled)
{
btnStartChat.setVisibility(View.GONE);
chSelectAll.setVisibility(View.GONE);
}
}
示例3: getGroupView
import android.widget.Button; //导入方法依赖的package包/类
/**
* Create the main view group. This is where we display the followed user's photo, email and display name
* @param groupPosition
* @param isExpanded
* @param convertView
* @param parent
* @return
*/
@Override
public View getGroupView(int groupPosition, boolean isExpanded, @Nullable View convertView, @NonNull ViewGroup parent) {
User user = (User) getGroup(groupPosition);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item_user, parent, false);
}
TextView displayNameView = (TextView) convertView.findViewById(R.id.userDisplayName);
TextView emailView = (TextView) convertView.findViewById(R.id.userEmail);
ImageView photoView = (ImageView) convertView.findViewById(R.id.userPhoto);
// Hide the button
Button socialActionButton = (Button) convertView.findViewById(R.id.socialActionButton);
socialActionButton.setVisibility(View.INVISIBLE);
displayNameView.setText(user.getDisplayName());
emailView.setText(user.getEmail());
photoView.setTag(user.getPhotoUrl());
new DownloadImageTask().execute(photoView);
return convertView;
}
示例4: set8thItemVisibility
import android.widget.Button; //导入方法依赖的package包/类
/**
* 设置第8位输入框显示状态,并设置是否清空其文本
* @param toShow 是否显示
* @param clearText 是否清空其文本内容
*/
public void set8thItemVisibility(boolean toShow, boolean clearText) {
final Button button8th = mButtonItems[7];
final boolean isShown = button8th.isShown();
// 显示第8位
if (toShow) {
if (!isShown) {// 第8位未显示,则设置显示
button8th.setVisibility(VISIBLE);
}
mButtonEndOf6.setVisibility(GONE);
mButtonKeyOf6.setVisibility(VISIBLE);
mButtonItems[6] = mButtonKeyOf6;
}else{
if (isShown) { // 隐藏第8位
button8th.setVisibility(GONE);
}
mButtonEndOf6.setVisibility(VISIBLE);
mButtonKeyOf6.setVisibility(GONE);
mButtonItems[6] = mButtonEndOf6;
}
if (clearText && !isButtonEmpty(button8th)) {
button8th.setText(null);
}
}
示例5: initView
import android.widget.Button; //导入方法依赖的package包/类
private void initView() {
mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
mRefreshLayout.setEnabled(false);
mLoadingLayout = (LoadingLayout) findViewById(R.id.loading_layout);
mRecyclerView = (RecyclerView) findViewById(R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new RetryActivity.RecyclerAdapter();
mRecyclerView.setAdapter(mAdapter);
mEmptyBtn = (Button) findViewById(R.id.empty_btn);
mRetryBtn = (Button) findViewById(R.id.retry_btn);
mCustomBtn1 = (Button) findViewById(R.id.custom1);
mCustomBtn2 = (Button) findViewById(R.id.custom2);
mRetryBtn.setVisibility(View.GONE);
mEmptyBtn.setVisibility(View.GONE);
mCustomBtn1.setVisibility(View.GONE);
mCustomBtn2.setVisibility(View.GONE);
mLoadingLayout.setOnRetryLoadListener(this);
}
示例6: initBaseProfile
import android.widget.Button; //导入方法依赖的package包/类
private void initBaseProfile() {
logger.d("detail#initBaseProfile");
IMBaseImageView portraitImageView = (IMBaseImageView) curView.findViewById(R.id.user_portrait);
setTextViewContent(R.id.nickName, currentUser.getMainName());
setTextViewContent(R.id.userName, currentUser.getRealName());
//头像设置
portraitImageView.setDefaultImageRes(R.drawable.tt_default_user_portrait_corner);
portraitImageView.setCorner(8);
portraitImageView.setImageResource(R.drawable.tt_default_user_portrait_corner);
portraitImageView.setImageUrl(currentUser.getAvatar());
portraitImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), DetailPortraitActivity.class);
intent.putExtra(IntentConstant.KEY_AVATAR_URL, currentUser.getAvatar());
intent.putExtra(IntentConstant.KEY_IS_IMAGE_CONTACT_AVATAR, true);
startActivity(intent);
}
});
// 设置界面信息
Button chatBtn = (Button) curView.findViewById(R.id.chat_btn);
if (currentUserId == imService.getLoginManager().getLoginId()) {
chatBtn.setVisibility(View.GONE);
}else{
chatBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
IMUIHelper.openChatActivity(getActivity(),currentUser.getSessionKey());
getActivity().finish();
}
});
}
}
示例7: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alert_dialog);
setCanceledOnTouchOutside(true);
tvTitle = (TextView) findViewById(R.id.tvAlertDialogTitle);
tvMessage = (TextView) findViewById(R.id.tvAlertDialogMessage);
btnPositive = (Button) findViewById(R.id.btnAlertDialogPositive);
btnNegative = (Button) findViewById(R.id.btnAlertDialogNegative);
tvTitle.setVisibility(StringUtil.isNotEmpty(title, true) ? View.VISIBLE : View.GONE);
tvTitle.setText("" + StringUtil.getCurrentString());
if (StringUtil.isNotEmpty(strPositive, true)) {
btnPositive.setText(StringUtil.getCurrentString());
}
btnPositive.setOnClickListener(this);
if (showNegativeButton) {
if (StringUtil.isNotEmpty(strNegative, true)) {
btnNegative.setText(StringUtil.getCurrentString());
}
btnNegative.setOnClickListener(this);
} else {
btnNegative.setVisibility(View.GONE);
}
tvMessage.setText(StringUtil.getTrimedString(message));
}
示例8: onCreateView
import android.widget.Button; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
getActivity().setTitle(getString(R.string.navprofile));
View view = inflater.inflate(R.layout.fragment_student_profile, container, false);
changePassword = (Button) view.findViewById(R.id.profile_btn_change_password);
changePassword.setOnClickListener(this);
confirmPassword = (Button) view.findViewById(R.id.profile_btn_confirm_pwd);
confirmPassword.setOnClickListener(this);
signOut = (Button) view.findViewById(R.id.profile_btn_signout);
signOut.setOnClickListener(this);
progressBar = (ProgressBar) view.findViewById(R.id.profile_progressbar);
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
newPassword = (EditText) view.findViewById(R.id.profile_newPassword);
newPassword.setVisibility(View.GONE);
confirmPassword.setVisibility(View.GONE);
return view;
}
示例9: builder
import android.widget.Button; //导入方法依赖的package包/类
public MyAlertDialog builder() {
// 获取Dialog布局
View view = LayoutInflater.from(context).inflate(
R.layout.view_alertdialog, null);
// 获取自定义Dialog布局中的控件
lLayout_bg = (LinearLayout) view.findViewById(R.id.lLayout_bg);
txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title.setVisibility(View.GONE);
txt_msg = (TextView) view.findViewById(R.id.txt_msg);
txt_msg.setVisibility(View.GONE);
btn_neg = (Button) view.findViewById(R.id.btn_neg);
btn_neg.setVisibility(View.GONE);
btn_pos = (Button) view.findViewById(R.id.btn_pos);
btn_pos.setVisibility(View.GONE);
img_line = (ImageView) view.findViewById(R.id.img_line);
img_line.setVisibility(View.GONE);
// 定义Dialog布局和参数
dialog = new Dialog(context, R.style.AlertDialogStyle);
dialog.setContentView(view);
dialog.setCancelable(false);
// 调整dialog背景大小
lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));
return this;
}
示例10: onStart
import android.widget.Button; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
final Activity activity = getActivity();
Button button2 = (Button) activity.findViewById(R.id.stranger_button2);
button2.setVisibility(View.GONE);
Button add = (Button) activity.findViewById(R.id.stranger_button1);
if (!checkPending(user)) {
add.setText("Add");
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addUser(user);
getActivity().finish();
}
});
} else {
add.setText("Pending");
}
if (CurrentUserSingleton.getInstance().getUser().getFriends().contains(user)){
Intent intent = new Intent(context, Profile.class);
intent.putExtra("name", user);
startActivity(intent);
getActivity().finish();
}
}
示例11: displayErrorAuthentification
import android.widget.Button; //导入方法依赖的package包/类
public void displayErrorAuthentification(){
if (mHandler.hasMessages(DIALOG_LISTING))
mHandler.removeMessages(DIALOG_LISTING);
mArchosGridView.setVisibility(View.GONE);
View emptyView = mRootView.findViewById(R.id.empty_view);
if (emptyView instanceof ViewStub) {
final ViewStub stub = (ViewStub) emptyView;
emptyView = stub.inflate();
}
View loading = mRootView.findViewById(R.id.loading);
if (loading != null)
loading.setVisibility(View.GONE);
if (emptyView != null) {
emptyView.setVisibility(View.VISIBLE);
// Update the text of the empty view
TextView emptyViewText = (TextView)emptyView.findViewById(R.id.empty_view_text);
emptyViewText.setTextAppearance(getActivity(), android.R.style.TextAppearance_Large);
emptyViewText.setText(R.string.error_credentials);
// Check if a button is needed in the empty view
Button emptyViewButton = (Button)emptyView.findViewById(R.id.empty_view_button);
// Show the button and update its label
emptyViewButton.setVisibility(View.VISIBLE);
emptyViewButton.setText(getEmptyViewButtonLabel());
emptyViewButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listFiles(false);
}
});
}
}
示例12: builder
import android.widget.Button; //导入方法依赖的package包/类
public CustomAlertDialog builder() {
view = LayoutInflater.from(context).inflate(R.layout.view_alertdialog, null);
lLayout_bg = (LinearLayout) view.findViewById(R.id.layout_bg);
txt_title = (TextView) view.findViewById(R.id.txt_title);
txt_title.setVisibility(View.GONE);
txt_msg = (TextView) view.findViewById(R.id.txt_msg);
txt_msg.setVisibility(View.GONE);
et_input = (EditText) view.findViewById(R.id.et_input);
et_input.setVisibility(View.GONE);
btn_neg = (Button) view.findViewById(R.id.btn_neg);
btn_neg.setVisibility(View.GONE);
btn_pos = (Button) view.findViewById(R.id.btn_pos);
btn_pos.setVisibility(View.GONE);
btn_mid = (Button) view.findViewById(R.id.btn_mid);
btn_mid.setVisibility(View.GONE);
line1 = (ImageView) view.findViewById(R.id.line1);
line1.setVisibility(View.GONE);
line2 = (ImageView) view.findViewById(R.id.line2);
line2.setVisibility(View.GONE);
dialog = new Dialog(context, R.style.AlertDialogStyle);
dialog.setContentView(view);
lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (
display.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));
return this;
}
示例13: getView
import android.widget.Button; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.sensor_list_item, parent, false);
LinearLayout itemLayout = (LinearLayout) rowView.findViewById(R.id.item_layout);
ImageView itemImageView = (ImageView) rowView.findViewById(R.id.item_image);
TextView itemNameView = (TextView) rowView.findViewById(R.id.item_name);
TextView itemStatus = (TextView) rowView.findViewById(R.id.item_status);
ToggleButton itemEnable = (ToggleButton) rowView.findViewById(R.id.item_enable);
ToggleButton itemActivate = (ToggleButton) rowView.findViewById(R.id.item_activate);
Button itemActuatorRun = (Button) rowView.findViewById(R.id.item_actuator_run);
itemEnable.setVisibility(View.GONE);
SensorInfo sensorInfo = sensorInfos.get(position);
itemImageView.setImageResource(sensorInfo.getType().getImage());
itemNameView.setText(sensorInfo.getType().getNickname());
// itemEnable.setChecked(sensorInfo.isEnable());
if (sensorInfo.getType().getCategory() == SensorType.Category.ACTUATOR) {
itemStatus.setVisibility(View.GONE);
itemActivate.setVisibility(View.GONE);
itemActuatorRun.setEnabled(sensorInfo.isActivated() && !sensorInfo.isSuspend());
}
else {
itemActuatorRun.setVisibility(View.GONE);
itemStatus.setText(sensorInfo.toString());
itemActivate.setChecked(sensorInfo.isActivated());
itemActivate.setEnabled(!sensorInfo.isSuspend());
}
// sensor item click
itemLayout.setTag(sensorInfo);
itemLayout.setOnClickListener(listItemClickListener);
// sensor activation button click
itemActivate.setTag(sensorInfo);
itemActivate.setOnClickListener(activateClickListener);
// actuator run button click
itemActuatorRun.setTag(sensorInfo);
itemActuatorRun.setOnClickListener(actuatorRunClickListener);
return rowView;
}
示例14: initViewsAndEvents
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void initViewsAndEvents(View view, Bundle savedInstanceState) {
ImageView ivOpenBg = (ImageView) view.findViewById(R.id.iv_open_bg);
mBtnOpen = (Button) view.findViewById(R.id.btn_open_money);
View closeLayout = view.findViewById(R.id.layout_closed);
TextView tvUserName = (TextView) view.findViewById(R.id.tv_username);
mTvGreeting = (TextView) view.findViewById(R.id.tv_greeting);
mAvatarView = view.findViewById(R.id.layout_avatar);
ImageView ivAvatar = (ImageView) view.findViewById(R.id.iv_avatar);
mTvTitle = (TextView) view.findViewById(R.id.tv_open_title);
mTvCheckLucky = (TextView) view.findViewById(R.id.tv_check_lucky);
mTvCheckLucky.setOnClickListener(this);
if (!TextUtils.isEmpty(mRedPacketInfo.senderAvatarUrl)) {
Glide.with(mContext).load(mRedPacketInfo.senderAvatarUrl)
.error(R.drawable.rp_avatar)
.placeholder(R.drawable.rp_avatar)
.transform(new CircleTransform(mContext))
.into(ivAvatar);
}
if (!TextUtils.isEmpty(RPPreferenceManager.getInstance().getOpenUrl())) {
Glide.with(mContext).load(RPPreferenceManager.getInstance().getOpenUrl())
.error(R.drawable.rp_open_packet_bg)
.into(ivOpenBg);
}
closeLayout.setOnClickListener(this);
mBtnOpen.setOnClickListener(this);
int status = mRedPacketInfo.status;
tvUserName.setText(mRedPacketInfo.senderNickname);
if (mRedPacketInfo.chatType == RPConstant.CHAT_TYPE_GROUP) {
mTvCheckLucky.setVisibility(View.VISIBLE);
if (mRedPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_GROUP_RANDOM)) {
mTvTitle.setText(R.string.title_random_money);
} else if (mRedPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_GROUP_AVERAGE)
|| mRedPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_GROUP_PRI)) {
mTvTitle.setText(R.string.send_you_money);
}
if (status == RPConstant.RED_PACKET_STATUS_RECEIVABLE) {//可以领取
if (mRedPacketInfo.messageDirect.equals(RPConstant.MESSAGE_DIRECT_RECEIVE)) {
mTvCheckLucky.setVisibility(View.INVISIBLE);
}
mBtnOpen.setVisibility(View.VISIBLE);
mTvGreeting.setText(mRedPacketInfo.redPacketGreeting);
} else if (status == RPConstant.RED_PACKET_STATUS_RECEIVED) {//领完了
mTvTitle.setVisibility(View.INVISIBLE);
if (mRedPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_GROUP_AVERAGE)
|| mRedPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_GROUP_PRI)) {
mTvCheckLucky.setVisibility(View.INVISIBLE);
mTvGreeting.setText(R.string.money_is_out_avg);
} else {
mTvGreeting.setText(R.string.money_is_out);
}
mBtnOpen.setVisibility(View.GONE);
} else if (status == RPConstant.RED_PACKET_STATUS_EXPIRED) {
mTvTitle.setVisibility(View.INVISIBLE);
mTvGreeting.setText(R.string.money_expired_str);
mTvCheckLucky.setVisibility(View.INVISIBLE);
mBtnOpen.setVisibility(View.GONE);
}
} else if (mRedPacketInfo.chatType == RPConstant.CHAT_TYPE_SINGLE) {
mTvCheckLucky.setVisibility(View.INVISIBLE);
if (status == RPConstant.RED_PACKET_STATUS_RECEIVABLE) {
mBtnOpen.setVisibility(View.VISIBLE);
mTvGreeting.setText(mRedPacketInfo.redPacketGreeting);
} else if (status == RPConstant.RED_PACKET_STATUS_EXPIRED) {
mBtnOpen.setVisibility(View.GONE);
tvUserName.setText(mRedPacketInfo.senderNickname);
mTvTitle.setVisibility(View.INVISIBLE);
mTvGreeting.setText(R.string.money_expired_str);
}
}
}
示例15: onCreateView
import android.widget.Button; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_tillcodefrag,container,false);
//ImageView image1 = (ImageView)v.findViewById(R.id.bannerfrag2);
//image1.setImageResource(getArguments().getInt("imageID"));
//set the text for textview extract the arguments
TextView heading1 = (TextView)v.findViewById(R.id.headingfrag2);
heading1.setText(getArguments().getString("headingValue"));
TextView content1 = (TextView)v.findViewById(R.id.articlefrag2);
String var = getArguments().getString("contentValue");
//noinspection deprecation
content1.setText(Html.fromHtml(var));
TextView code1 = (TextView)v.findViewById(R.id.codefrag2);
String codev = getArguments().getString("codeValue");
//noinspection deprecation
code1.setText(Html.fromHtml(codev));
TextView subcontent = (TextView)v.findViewById(R.id.subarticlefrag2);
String var1 = getArguments().getString("subarticle");
//noinspection deprecation
subcontent.setText(Html.fromHtml(var1));
Button next = (Button)v.findViewById(R.id.nextpage2);
LinearLayout slider = (LinearLayout)v.findViewById(R.id.slidenextcodefrag);
int decide = getArguments().getInt("yup");
int casetitle = getArguments().getInt("caseno");
if(decide == 1)
{
slider.setVisibility(View.GONE);
next.setVisibility(View.VISIBLE);
}
//do next visibility check then onclicklistner
if(next.getVisibility()==View.VISIBLE)
{
switch (casetitle)
{
case 11:
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(),TutorialsFinishedActivity.class);
intent.putExtra("title",'j'); //exception handling
startActivity(intent);
}
});
break;
}
}
return v;
}