Java Code Examples for android.widget.Button#getVisibility()

The following examples show how to use android.widget.Button#getVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessControl3Activity.java    From diva-android with GNU General Public License v3.0 6 votes vote down vote up
public void addPin(View view) {
    SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor spedit = spref.edit();
    EditText pinTxt = (EditText) findViewById(R.id.aci3Pin);
    String pin = pinTxt.getText().toString();

    if (pin == null || pin.isEmpty()) {
        Toast.makeText(this, "Please Enter a valid pin!", Toast.LENGTH_SHORT).show();
    }
    else {
        Button vbutton = (Button) findViewById(R.id.aci3viewbutton);
        spedit.putString(getString(R.string.pkey), pin);
        spedit.commit();
        if (vbutton.getVisibility() != View.VISIBLE) {
            vbutton.setVisibility(View.VISIBLE);
        }

        Toast.makeText(this, "PIN Created successfully. Private notes are now protected with PIN", Toast.LENGTH_SHORT).show();
    }
}
 
Example 2
Source File: ECAlertDialog.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
public void show() {
    super.show();

    int i = 0;
    Button btn = null;
    Iterator<Button> iterator = mButtons.iterator();
    while (iterator.hasNext()) {
        Button button = iterator.next();
        if(button.getVisibility() != View.VISIBLE) {
            continue;
        }
        ++i;
        btn = button;
    }
    if (i == 1) {
        btn.setBackgroundResource(R.drawable.btn_dialog_single);
    }
    if (i == 2) {
        btn.setSelected(true);
        ((ViewGroup.MarginLayoutParams)(this.mButtons.get(0)).getLayoutParams()).rightMargin = 1;
    }
    if (i == 3)  {
        btn.setSelected(true);
        ((ViewGroup.MarginLayoutParams)(this.mButtons.get(2)).getLayoutParams()).leftMargin = 1;
        ((ViewGroup.MarginLayoutParams)(this.mButtons.get(0)).getLayoutParams()).rightMargin = 1;
    }

}
 
Example 3
Source File: ProgressDialog.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private boolean isButtonVisible(int which) {
    Button button = getButton(which);
    if (button==null) {
        return false;
    }
    return button.getVisibility()==View.VISIBLE;
}
 
Example 4
Source File: MainActivity.java    From AndroidAutoClick with MIT License 4 votes vote down vote up
/**
 * 设置插屏广告
 */
private void setupSpotAd() {
	// 预加载插屏广告数据
	SpotManager.getInstance(mContext).loadSpotAds();
	// 设置插屏动画的横竖屏展示方式,如果设置了横屏,则在有广告资源的情况下会是优先使用横屏图
	SpotManager.getInstance(mContext)
			.setSpotOrientation(SpotManager.ORIENTATION_LANDSCAPE);
	// 插屏动画效果,0:ANIM_NONE为无动画,1:ANIM_SIMPLE为简单动画效果,2:ANIM_ADVANCE为高级动画效果
	SpotManager.getInstance(mContext).setAnimationType(SpotManager.ANIM_ADVANCE);

	Button btnShowSpot = (Button) findViewById(R.id.btn_show_spot);
	if (btnShowSpot.getVisibility() == View.GONE) {
		btnShowSpot.setVisibility(View.VISIBLE);
	}

	btnShowSpot.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			// 展示插屏广告,可以不调用预加载方法独立使用

			//从这里入手,分析插屏广告代码,找到对应的广告view
			SpotManager.getInstance(mContext)
					.showSpotAds(mContext, new SpotDialogListener() {
						@Override
						public void onShowSuccess() {
							Log.i(TAG, "插屏展示成功");
							//获取插屏广告View
							getO();
						}

						@Override
						public void onShowFailed() {
							Log.i(TAG, "插屏展示失败");
						}

						@Override
						public void onSpotClosed() {
							Log.i(TAG, "插屏被关闭");
						}

						@Override
						public void onSpotClick(boolean isWebPath) {
							Log.i(TAG, "插屏被点击,isWebPath = " + isWebPath);
						}

					});
		}
	});
}
 
Example 5
Source File: MainActivity.java    From AndroidAutoClick with MIT License 4 votes vote down vote up
/**
 * 设置原生插屏广告
 */
public void setNativeSpotAd() {
	mNativeAdLayout = (RelativeLayout) findViewById(R.id.rl_native_ad);

	// 设置插屏动画的横竖屏展示方式,如果设置了横屏,则在有广告资源的情况下会是优先使用横屏图
	SpotManager.getInstance(mContext)
			.setSpotOrientation(SpotManager.ORIENTATION_LANDSCAPE);

	Button btnShowNativeSpot = (Button) findViewById(R.id.btn_show_native_spot);
	if (btnShowNativeSpot.getVisibility() == View.GONE) {
		btnShowNativeSpot.setVisibility(View.VISIBLE);
	}
	btnShowNativeSpot.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			if (mNativeAdLayout != null && mNativeAdLayout.getVisibility() == View.GONE) {
				mNativeAdLayout.setVisibility(View.VISIBLE);
			}
			if (mCustomerSpotView != null && mCustomerSpotView.isAttachedOnWindow()) {
				SpotManager.getInstance(mContext).handlerClick();
			} else {
				new Thread(new Runnable() {
					@Override
					public void run() {
						//切换到子线程获取原生控件
						mCustomerSpotView = SpotManager.getInstance(mContext)
								.cacheCustomerSpot(mContext, new SpotDialogListener() {
									@Override
									public void onShowSuccess() {
										Log.i(TAG, "原生插屏展示成功");
									}

									@Override
									public void onShowFailed() {
										Log.i(TAG, "原生插屏展示失败");
									}

									@Override
									public void onSpotClosed() {
										Log.i(TAG, "原生插屏被关闭");
									}

									@Override
									public void onSpotClick(boolean isWebPath) {
										Log.i(TAG, "原生插屏被点击,isWebPath = " + isWebPath);
									}
								});
						//获取成功
						if (mCustomerSpotView != null) {
							//切换到UI线程
							runOnUiThread(new Runnable() {
								@Override
								public void run() {
									RelativeLayout.LayoutParams params =
											new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
													ViewGroup.LayoutParams.MATCH_PARENT);
									params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
									if (mNativeAdLayout != null) {
										mNativeAdLayout.removeAllViews();
										mNativeAdLayout.addView(mCustomerSpotView, params);
									}
								}
							});
						} else {
							//获取失败
							runOnUiThread(new Runnable() {
								@Override
								public void run() {
									Toast.makeText(mContext, "Please try again later.", Toast.LENGTH_SHORT).show();
								}
							});
						}
					}
				}).start();
			}
		}
	});
}