android.widget.CheckBox#setVisibility ( )源码实例Demo

下面列出了android.widget.CheckBox#setVisibility ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FairEmail   文件: FragmentAnswer.java

@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    Spanned spanned = HtmlHelper.fromHtml("<p>" +
            getString(R.string.title_answer_template_name) +
            "<br>" +
            getString(R.string.title_answer_template_email) +
            "</p>", false, getContext());

    View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null);
    TextView tvMessage = dview.findViewById(R.id.tvMessage);
    CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);

    tvMessage.setText(spanned);
    cbNotAgain.setVisibility(View.GONE);

    return new AlertDialog.Builder(getContext())
            .setView(dview)
            .setNegativeButton(android.R.string.cancel, null)
            .create();
}
 
源代码2 项目: XPrivacyLua   文件: ActivityMain.java

@Override
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    View row;
    if (null == convertView)
        row = LayoutInflater.from(getContext()).inflate(this.resource, null);
    else
        row = convertView;

    DrawerItem item = getItem(position);

    TextView tv = row.findViewById(R.id.tvItem);
    CheckBox cb = row.findViewById(R.id.cbItem);
    tv.setText(item.getTitle());
    cb.setVisibility(item.isCheckable() ? View.VISIBLE : View.GONE);
    cb.setChecked(item.isChecked());

    return row;
}
 
源代码3 项目: MHViewer   文件: SetSecurityActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_set_security);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
    mCancel = ViewUtils.$$(this, R.id.cancel);
    mSet = ViewUtils.$$(this, R.id.set);
    mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);

    String pattern = Settings.getSecurity();
    if (!TextUtils.isEmpty(pattern)) {
        mPatternView.setPattern(LockPatternView.DisplayMode.Correct,
                LockPatternUtils.stringToPattern(pattern));
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
        // The line below prevents the false positive inspection from Android Studio
        // noinspection ResourceType
        if (fingerprintManager != null && hasEnrolledFingerprints(fingerprintManager)) {
            mFingerprint.setVisibility(View.VISIBLE);
            mFingerprint.setChecked(Settings.getEnableFingerprint());
        }
    }

    mCancel.setOnClickListener(this);
    mSet.setOnClickListener(this);
}
 
源代码4 项目: AndroidAPS   文件: SWCheckbox.java

@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();
    // Get if there is already value in SP
    Boolean previousValue;
    previousValue = SP.getBoolean(preferenceId, false);
    checkBox = new CheckBox(context);
    checkBox.setText(label);
    checkBox.setChecked(previousValue);
    checkBox.setVisibility(View.VISIBLE);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            ArrayList<PluginBase> pluginsInCategory;
            pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.PUMP);
            PluginBase found = null;
            for (PluginBase p : pluginsInCategory) {
                if (p.isEnabled(PluginType.PUMP) && found == null) {
                    found = p;
                } else if (p.isEnabled(PluginType.PUMP)) {
                    // set others disabled
                    p.setPluginEnabled(PluginType.PUMP, false);
                }
            }
            log.debug("Enabled pump plugin:"+found.getClass());
            save(checkBox.isChecked());
        }
    });
    layout.addView(checkBox);
    super.generateDialog(layout);
}
 

@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
    View cv = convertView;
    if (cv == null) {
        cv = mInflater.inflate(R.layout.item_irkitdevice_list, parent, false);
    } else {
        cv = convertView;
    }

    final VirtualDeviceContainer device = getItem(position);

    String name = device.getLabel();

    TextView nameView = (TextView) cv.findViewById(R.id.devicelist_package_name);
    nameView.setText(name);
    Drawable icon = device.getIcon();
    if (icon != null) {
        ImageView iconView = (ImageView) cv.findViewById(R.id.devicelist_icon);
        iconView.setImageDrawable(icon);
    }

    CheckBox removeCheck = (CheckBox) cv.findViewById(R.id.delete_check);
    if (mIsRemoved) {
        removeCheck.setVisibility(View.VISIBLE);
        removeCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                mIsRemoves.set(position, b);
            }
        });
        removeCheck.setChecked(device.isRemove());
        removeCheck.setFocusable(false);
    } else {
        removeCheck.setVisibility(View.GONE);
        removeCheck.setOnCheckedChangeListener(null);
    }
    return cv;
}
 

@Override
public View getView(final int position, View convertView, ViewGroup viewGroup) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.item_fabo_service_list, null);
    }

    final DConnectService service = (DConnectService) getItem(position);
    convertView.setTag(service);
    convertView.setBackgroundResource(service.isOnline() ?
            R.color.service_list_item_background_online :
            R.color.service_list_item_background_offline);

    TextView statusView = convertView.findViewById(R.id.service_online_status);
    statusView.setText(service.isOnline() ?
            R.string.activity_fabo_service_online :
            R.string.activity_fabo_service_offline);

    TextView nameView = convertView.findViewById(R.id.service_name);
    nameView.setText(service.getName());

    CheckBox checkBox = convertView.findViewById(R.id.activity_fabo_service_removal_checkbox);
    checkBox.setVisibility(hasCheckbox(service) ? View.VISIBLE : View.GONE);
    checkBox.setChecked(mRemoveServices.contains(service));

    ImageView imageView = (ImageView) convertView.findViewById(R.id.activity_fabo_service_edit);
    imageView.setVisibility(hasImageView(service) ? View.VISIBLE : View.GONE);

    return convertView;
}
 
源代码7 项目: EhViewer   文件: SetSecurityActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_set_security);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
    mCancel = ViewUtils.$$(this, R.id.cancel);
    mSet = ViewUtils.$$(this, R.id.set);
    mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);

    String pattern = Settings.getSecurity();
    if (!TextUtils.isEmpty(pattern)) {
        mPatternView.setPattern(LockPatternView.DisplayMode.Correct,
                LockPatternUtils.stringToPattern(pattern));
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
        // The line below prevents the false positive inspection from Android Studio
        // noinspection ResourceType
        if (fingerprintManager != null && hasEnrolledFingerprints(fingerprintManager)) {
            mFingerprint.setVisibility(View.VISIBLE);
            mFingerprint.setChecked(Settings.getEnableFingerprint());
        }
    }

    mCancel.setOnClickListener(this);
    mSet.setOnClickListener(this);
}
 
源代码8 项目: BotLibre   文件: CreateReplyActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_create_reply);
       
       if (MainActivity.instance instanceof ForumConfig) {
       	HttpGetImageAction.fetchImage(this, MainActivity.instance.avatar, findViewById(R.id.icon));
       } else {
       	((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.icon);
       }
       
       TextView text = (TextView) findViewById(R.id.topicText);
       text.setText(MainActivity.post.topic);
       
       CheckBox checkbox = (CheckBox) findViewById(R.id.replyToParentCheckBox);
       if (MainActivity.post.parent != null && MainActivity.post.parent.length() != 0) {
       	checkbox.setChecked(true);
       } else {
       	checkbox.setVisibility(View.GONE);
       }
       
       final WebView web = (WebView) findViewById(R.id.detailsLabel);
       web.loadDataWithBaseURL(null, MainActivity.post.detailsText, "text/html", "utf-8", null);
       
       web.setWebViewClient(new WebViewClient() {
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
           	try {
           		view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
           	} catch (Exception failed) {
           		return false;
           	}
               return true;
           }
       });
}
 
源代码9 项目: BotLibre   文件: CreateReplyActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_create_reply);
       
       if (MainActivity.instance instanceof ForumConfig) {
       	HttpGetImageAction.fetchImage(this, MainActivity.instance.avatar, findViewById(R.id.icon));
       } else {
       	((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.icon,80,80);
       }
       
       TextView text = (TextView) findViewById(R.id.topicText);
       text.setText(MainActivity.post.topic);
       
       CheckBox checkbox = (CheckBox) findViewById(R.id.replyToParentCheckBox);
       if (MainActivity.post.parent != null && MainActivity.post.parent.length() != 0) {
       	checkbox.setChecked(true);
       } else {
       	checkbox.setVisibility(View.GONE);
       }
       
       final WebView web = (WebView) findViewById(R.id.detailsLabel);
       web.loadDataWithBaseURL(null, MainActivity.post.detailsText, "text/html", "utf-8", null);
       
       web.setWebViewClient(new WebViewClient() {
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
           	try {
           		view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
           	} catch (Exception failed) {
           		return false;
           	}
               return true;
           }
       });
}
 
源代码10 项目: Nimingban   文件: CheckBoxDialogBuilder.java

@SuppressLint("InflateParams")
public CheckBoxDialogBuilder(Context context, CharSequence message, String checkText, boolean showCheckbox, boolean checked) {
    super(context);
    View view = LayoutInflater.from(context).inflate(R.layout.dialog_checkbox_builder, null);
    setView(view);
    TextView messageView = (TextView) view.findViewById(R.id.message);
    mShowCheckbox = showCheckbox;
    mCheckBox = (CheckBox) view.findViewById(R.id.checkbox);
    messageView.setText(message);
    mCheckBox.setText(checkText);
    mCheckBox.setChecked(checked);
    if (!showCheckbox) mCheckBox.setVisibility(View.GONE);
}
 
源代码11 项目: SuperNote   文件: RvNoteListAdapter.java

/**
 * 是否显示多选按钮
 *
 * @describe
 */
private void showCheckBox(CheckBox checkBox, int position) {
    if (NoteListConstans.isShowMultiSelectAction) {
        checkBox.setVisibility(View.VISIBLE);
        if (mCheckList.get(position))
            checkBox.setChecked(true);
        else
            checkBox.setChecked(false);
    } else {
        checkBox.setVisibility(View.INVISIBLE);
        checkBox.setChecked(false);
    }
}
 
源代码12 项目: qplayer-sdk   文件: SettingView.java

private View generateGroupView(int groupPosition, String title, String summery, View convertView) {    	   
    if (null == convertView) 
        convertView = mInflater.inflate(R.layout.set_item, null);              
    ImageView mImageView = (ImageView) convertView.findViewById(R.id.icon);   
    switch(groupPosition) {
    case POS_VIDEOQUALITY:
    	mImageView.setImageResource(R.drawable.set_videoquality);
    	break;
    case POS_DOWNLOADFILE:
    	mImageView.setImageResource(R.drawable.set_subtitle);
    	break;
    case POS_COLORTYPE:
    	mImageView.setImageResource(R.drawable.set_color);
    	break;     
    case POS_VIDEODEC:
    	mImageView.setImageResource(R.drawable.set_subtitle);
    	break;  	
    }
    
    TextView mTitle = (TextView) convertView.findViewById(R.id.title);
    mTitle.setText(title);
    TextView mSummery = (TextView) convertView.findViewById(R.id.summary);
    mSummery.setText(summery);
    CheckBox mCheckBox = (CheckBox) convertView.findViewById(R.id.checkbox);
   
    if (mLstValue.get(groupPosition).size() == 1)
    	mCheckBox.setChecked(mLstValue.get(groupPosition).get(0));
    
    ImageView mArrow = (ImageView) convertView.findViewById(R.id.selectedIcon);
    if (getChildrenCount(groupPosition) == 0) {
        mCheckBox.setVisibility(View.VISIBLE);
        mArrow.setVisibility(View.GONE);
    } else {
        mCheckBox.setVisibility(View.GONE);
        mArrow.setVisibility(View.VISIBLE);
    }
    return convertView;
}
 

private void prepareUI(String shareUri) {
  mSharePathEditText = (EditText) findViewById(R.id.share_path);
  mUsernameEditText = (EditText) findViewById(R.id.username);
  mDomainEditText = (EditText) findViewById(R.id.domain);
  mPasswordEditText = (EditText) findViewById(R.id.password);

  CheckBox passwordCheckbox = (CheckBox) findViewById(R.id.needs_password);
  mPinShareCheckbox = (CheckBox) findViewById(R.id.pin_share);

  mSharePathEditText.setText(shareUri);
  mSharePathEditText.setEnabled(false);

  passwordCheckbox.setVisibility(View.GONE);
  mPinShareCheckbox.setVisibility(View.VISIBLE);

  Button mLoginButton = (Button) findViewById(R.id.mount);
  mLoginButton.setText(getResources().getString(R.string.login));
  mLoginButton.setOnClickListener(mLoginListener);

  final Button cancel = (Button) findViewById(R.id.cancel);
  cancel.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      finish();
    }
  });
}
 

@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.wifi_auth_layout);
      
      Intent intent = getIntent();
	   	
	   	try {
	url = new URL (intent.getStringExtra (WifiAuthenticator.OPTION_URL));
} catch (MalformedURLException e) {
	// TODO
}
	   	String html = intent.getStringExtra (WifiAuthenticator.OPTION_PAGE);
	   	
	   	wifiAuth = new WifiAuthenticator (new Worker (new Logger (intent), this), url);
	   	parsedPage = new ParsedHttpInput (wifiAuth, url, html, new HashMap<String,String>());
	   	authParams = wifiAuth.getStoredAuthParams();
 		authParams = parsedPage.addMissingParams(authParams);
 		
 		fieldsTable = (TableLayout)findViewById(R.id.fieldsTableLayout);
 		fieldsTable.removeAllViews();
 		edits.clear();
 		Log.d(Constants.TAG, "Adding controls...");
 		HtmlInput passwordField = authParams.getFieldByType(HtmlInput.TYPE_PASSWORD);
	   	for (HtmlInput i : authParams.getFields()) {
	   		if (i != passwordField)
	   			addField (i);
	   	}

	   	checkSavePassword = (CheckBox)findViewById(R.id.checkSavePassword);

	   	if (passwordField != null)
	   		addField (passwordField);
	   	else if (checkSavePassword != null) {
 			checkSavePassword.setVisibility (View.GONE);
 			checkSavePassword = null;
 		}
	   	
  	buttonAuthenticate = (Button) findViewById(R.id.buttonAuthenticate);
  	checkAlwaysDoThat = (CheckBox)findViewById(R.id.checkAlwaysDoThat);
  	
  	performAction (authParams.authAction); 
  }
 

private void populateTriggerBtDevices(int spinnerViewId, int checkBoxViewId, VoiceSettingParamType voiceSettingParamType) {
    MultiSelectionTriggerSpinner btDevicesSpinner = findViewById(spinnerViewId);
    CheckBox allBtCheckbox = findViewById(checkBoxViewId);
    btDevicesSpinner.setVoiceSettingId(voiceSettingId);

    BluetoothAdapter bluetoothAdapter = Utils.getBluetoothAdapter(getBaseContext());

    if (bluetoothAdapter == null) {
        btDevicesSpinner.setVisibility(View.GONE);
        allBtCheckbox.setVisibility(View.GONE);
        return;
    } else {
        btDevicesSpinner.setVisibility(View.VISIBLE);
        allBtCheckbox.setVisibility(View.VISIBLE);
    }

    Set<BluetoothDevice> bluetoothDeviceSet = bluetoothAdapter.getBondedDevices();

    ArrayList<MultiselectionItem> items = new ArrayList<>();
    ArrayList<MultiselectionItem> selection = new ArrayList<>();
    ArrayList<String> selectedItems = new ArrayList<>();

    String enabledBtDevices = voiceSettingParametersDbHelper.getStringParam(
            voiceSettingId,
            voiceSettingParamType.getVoiceSettingParamTypeId());
    Boolean enabledVoiceDevices = voiceSettingParametersDbHelper.getBooleanParam(
            voiceSettingId,
            voiceSettingParamType.getVoiceSettingParamTypeId());
    if ((enabledVoiceDevices != null) && enabledVoiceDevices) {
        allBtCheckbox.setChecked(true);
        findViewById(R.id.trigger_bt_when_devices).setVisibility(View.GONE);
    } else {
        findViewById(R.id.trigger_bt_when_devices).setVisibility(View.VISIBLE);
    }

    if (enabledBtDevices != null) {
        for (String btDeviceAddress: enabledBtDevices.split(",")) {
            selectedItems.add(btDeviceAddress);
        }
    }

    for(BluetoothDevice bluetoothDevice: bluetoothDeviceSet) {
        String currentDeviceName = bluetoothDevice.getName();
        String currentDeviceAddress = bluetoothDevice.getAddress();
        MultiselectionItem multiselectionItem;
        if (selectedItems.contains(currentDeviceAddress)) {
            multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress, true);
            selection.add(multiselectionItem);
        } else {
            multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress,false);
        }
        items.add(multiselectionItem);
    }
    btDevicesSpinner.setItems(items);
    btDevicesSpinner.setSelection(selection);
}
 

private void populateBtDevices(int spinnerViewId, int checkBoxViewId, VoiceSettingParamType voiceSettingParamType) {
    MultiSelectionSpinner btDevicesSpinner = findViewById(spinnerViewId);
    CheckBox allBtCheckbox = findViewById(checkBoxViewId);
    View btDevicePanel = findViewById(R.id.tts_bt_device_panel);
    btDevicesSpinner.setVoiceSettingId(voiceSettingId);

    BluetoothAdapter bluetoothAdapter = Utils.getBluetoothAdapter(getBaseContext());

    if (bluetoothAdapter == null) {
        btDevicesSpinner.setVisibility(View.GONE);
        allBtCheckbox.setVisibility(View.GONE);
        btDevicePanel.setVisibility(View.GONE);
        return;
    } else {
        btDevicesSpinner.setVisibility(View.VISIBLE);
        allBtCheckbox.setVisibility(View.VISIBLE);
        btDevicePanel.setVisibility(View.VISIBLE);
    }

    Set<BluetoothDevice> bluetoothDeviceSet = bluetoothAdapter.getBondedDevices();

    ArrayList<MultiselectionItem> items = new ArrayList<>();
    ArrayList<MultiselectionItem> selection = new ArrayList<>();
    ArrayList<String> selectedItems = new ArrayList<>();

    String enabledBtDevices = voiceSettingParametersDbHelper.getStringParam(
            voiceSettingId,
            voiceSettingParamType.getVoiceSettingParamTypeId());
    Boolean enabledVoiceDevices = voiceSettingParametersDbHelper.getBooleanParam(
            voiceSettingId,
            voiceSettingParamType.getVoiceSettingParamTypeId());
    if ((enabledVoiceDevices != null) && enabledVoiceDevices) {
        allBtCheckbox.setChecked(true);
        findViewById(R.id.bt_when_devices).setVisibility(View.GONE);
    } else {
        findViewById(R.id.bt_when_devices).setVisibility(View.VISIBLE);
    }

    if (enabledBtDevices != null) {
        for (String btDeviceName: enabledBtDevices.split(",")) {
            selectedItems.add(btDeviceName);
        }
    }

    for(BluetoothDevice bluetoothDevice: bluetoothDeviceSet) {
        String currentDeviceName = bluetoothDevice.getName();
        String currentDeviceAddress = bluetoothDevice.getAddress();
        MultiselectionItem multiselectionItem;
        if (selectedItems.contains(currentDeviceAddress)) {
            multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress, true);
            selection.add(multiselectionItem);
        } else {
            multiselectionItem = new MultiselectionItem(currentDeviceName, currentDeviceAddress,false);
        }
        items.add(multiselectionItem);
    }
    btDevicesSpinner.setItems(items);
    btDevicesSpinner.setSelection(selection);
}
 
源代码17 项目: SSForms   文件: TextDetailDocumentsCell.java

@SuppressLint("RtlHardcoded")
public TextDetailDocumentsCell(Context context) {

    super(context);

    density = context.getResources().getDisplayMetrics().density;
    checkDisplaySize();

    textView = new TextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT);
    addView(textView);
    LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.topMargin = AndroidUtilities.dp(10, density);
    layoutParams.leftMargin = AndroidUtilities.dp(71, density);
    layoutParams.rightMargin = AndroidUtilities.dp(16, density);
    layoutParams.gravity = Gravity.LEFT;
    textView.setLayoutParams(layoutParams);

    valueTextView = new TextView(context);
    valueTextView.setTextColor(0xff8a8a8a);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(Gravity.LEFT);
    addView(valueTextView);
    layoutParams = (LayoutParams) valueTextView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.topMargin = AndroidUtilities.dp(35, density);
    layoutParams.leftMargin = AndroidUtilities.dp(71, density);
    layoutParams.rightMargin = AndroidUtilities.dp(16, density);
    layoutParams.gravity = Gravity.LEFT;
    valueTextView.setLayoutParams(layoutParams);

    typeTextView = new TextView(context);
    typeTextView.setBackgroundColor(0xff757575);
    typeTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    typeTextView.setGravity(Gravity.CENTER);
    typeTextView.setSingleLine(true);
    typeTextView.setTextColor(0xffd1d1d1);
    typeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    typeTextView.setTypeface(Typeface.DEFAULT_BOLD);
    addView(typeTextView);
    layoutParams = (LayoutParams) typeTextView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(40, density);
    layoutParams.height = AndroidUtilities.dp(40, density);
    layoutParams.leftMargin = AndroidUtilities.dp(16, density);
    layoutParams.rightMargin = AndroidUtilities.dp(0, density);
    layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    typeTextView.setLayoutParams(layoutParams);

    imageView = new ImageView(context);
    addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(40, density);
    layoutParams.height = AndroidUtilities.dp(40, density);
    layoutParams.leftMargin = AndroidUtilities.dp(16, density);
    layoutParams.rightMargin = AndroidUtilities.dp(0, density);
    layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    imageView.setLayoutParams(layoutParams);

    checkBox = new CheckBox(context);
    checkBox.setVisibility(GONE);
    addView(checkBox);
    layoutParams = (LayoutParams) checkBox.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(22, density);
    layoutParams.height = AndroidUtilities.dp(22, density);
    layoutParams.topMargin = AndroidUtilities.dp(34, density);
    layoutParams.leftMargin = AndroidUtilities.dp(38, density) ;
    layoutParams.rightMargin = 0;
    layoutParams.gravity = Gravity.LEFT;
    checkBox.setLayoutParams(layoutParams);
}
 

public void showNoticeDialog(final Context context, final UpdateResponse response) {
	if(response != null && TextUtils.isEmpty(response.path)){
		return;
	}
	StringBuilder updateMsg = new StringBuilder();
	updateMsg.append(response.version);
	updateMsg.append(context.getString(R.string.analysissdk_update_new_impress));
	updateMsg.append("\n");
	updateMsg.append(response.content);
	updateMsg.append("\n");
	updateMsg.append(context.getString(R.string.analysissdk_update_apk_size, sizeToString(response.size)));
	
	final Dialog dialog = new Dialog(context, R.style.AnalysisSDK_CommonDialog);
	dialog.setContentView(R.layout.analysissdk_update_notify_dialog);
	TextView tvContent = (TextView) dialog.findViewById(R.id.update_tv_dialog_content);
	tvContent.setMovementMethod(ScrollingMovementMethod.getInstance()); 
	tvContent.setText(updateMsg);

	final CheckBox cBox = (CheckBox) dialog.findViewById(R.id.update_cb_ignore);		
	if(UpdateConfig.isUpdateForce()){
		cBox.setVisibility(View.GONE);
	}else {
		cBox.setVisibility(View.VISIBLE);
	}
	
	android.view.View.OnClickListener ocl = new android.view.View.OnClickListener() {
		public void onClick(View v) {
			if(v.getId() == R.id.update_btn_dialog_ok){
				dialogBtnClick = UpdateStatus.Update;
			}else if(v.getId() == R.id.update_btn_dialog_cancel){
				if(cBox.isChecked()){
					dialogBtnClick = UpdateStatus.Ignore;
				}
			}
			dialog.dismiss();
			UpdateAgent.updateDialogDismiss(context, dialogBtnClick, response);
		}
	};
		
	dialog.findViewById(R.id.update_btn_dialog_ok).setOnClickListener(ocl);
	dialog.findViewById(R.id.update_btn_dialog_cancel).setOnClickListener(ocl);
	dialog.setCanceledOnTouchOutside(false);
	dialog.setCancelable(true);
	dialog.show();
	
}
 
源代码19 项目: ArscEditor   文件: DoTranslate.java

@SuppressLint("InflateParams")
public void init(int _position) {
	// 获取需要翻译的条目所在位置
	position = _position;

	LayoutInflater factory = LayoutInflater.from(mContext);
	// 得到自定义对话框
	View DialogView = factory.inflate(R.layout.translate, null);
	// 创建对话框
	new AlertDialog.Builder(mContext).setView(DialogView)// 设置自定义对话框的样式
			.setTitle(R.string.translate) // 设置进度条对话框的标题
			.setNegativeButton(R.string.translate, new DialogInterface.OnClickListener() // 设置按钮,并监听
			{
				@SuppressWarnings("unchecked")
				@Override
				public void onClick(DialogInterface p1, int p2) {
					// 开启一个翻译线程
					new translate_task().execute(source_list, target_list);
				}
			}).create()// 创建
			.show(); // 显示对话框

	// 找到显示源语言的Spinner控件
	src_type = (Spinner) DialogView.findViewById(R.id.src_type);
	// 找到显示目标语言的Spinner控件
	translate_to = (Spinner) DialogView.findViewById(R.id.translate_to);
	// 找到翻译商的选项的Spinner控件
	translator = (Spinner) DialogView.findViewById(R.id.translator);
	// 找到显示跳过选项的CheckBox控件
	skip_already_translate = (CheckBox) DialogView.findViewById(R.id.skip_already_translate);

	// 源语言默认自动识别
	src_type.setSelection(0);
	// 翻译为默认选择中文
	translate_to.setSelection(1);
	// 默认选择百度翻译
	translator.setSelection(0);
	// 如果是翻译单个条目,需要隐藏“跳过已翻译的内容”的选项,否则需要显示该选项
	skip_already_translate.setVisibility(translate_all ? View.VISIBLE : View.GONE);
	skip_already_translate.setOnCheckedChangeListener(this);
}
 
源代码20 项目: Overchan-Android   文件: PostFormActivity.java

private void setViews() {
    setContentView(settings.isPinnedMarkup() ? R.layout.postform_layout_pinned_markup : R.layout.postform_layout);
    nameLayout = findViewById(R.id.postform_name_email_layout);
    nameField = (EditText) findViewById(R.id.postform_name_field);
    emailField = (EditText) findViewById(R.id.postform_email_field);
    passwordLayout = findViewById(R.id.postform_password_layout);
    passwordField = (EditText) findViewById(R.id.postform_password_field);
    chkboxLayout = findViewById(R.id.postform_checkbox_layout);
    sageChkbox = (CheckBox) findViewById(R.id.postform_sage_checkbox);
    sageChkbox.setOnClickListener(this);
    custommarkChkbox = (CheckBox) findViewById(R.id.postform_custommark_checkbox);
    attachmentsLayout = (LinearLayout) findViewById(R.id.postform_attachments_layout);
    spinner = (Spinner) findViewById(R.id.postform_spinner);
    subjectField = (EditText) findViewById(R.id.postform_subject_field);
    commentField = (EditText) findViewById(R.id.postform_comment_field);
    markLayout = (LinearLayout) findViewById(R.id.postform_mark_layout);
    for (int i=0, len=markLayout.getChildCount(); i<len; ++i) markLayout.getChildAt(i).setOnClickListener(this);
    captchaLayout = findViewById(R.id.postform_captcha_layout);
    captchaView = (ImageView) findViewById(R.id.postform_captcha_view);
    captchaView.setOnClickListener(this);
    captchaView.setOnCreateContextMenuListener(this);
    captchaLoading = findViewById(R.id.postform_captcha_loading);
    captchaField = (EditText) findViewById(R.id.postform_captcha_field);
    captchaField.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                send();
                return true;
            }
            return false;
        }
    });
    sendButton = (Button) findViewById(R.id.postform_send_button);
    sendButton.setOnClickListener(this);
    
    if (settings.isHidePersonalData()) {
        nameLayout.setVisibility(View.GONE);
        passwordLayout.setVisibility(View.GONE);
    } else {
        nameLayout.setVisibility(boardModel.allowNames || boardModel.allowEmails ? View.VISIBLE : View.GONE);
        nameField.setVisibility(boardModel.allowNames ? View.VISIBLE : View.GONE);
        emailField.setVisibility(boardModel.allowEmails ? View.VISIBLE : View.GONE);
        passwordLayout.setVisibility((boardModel.allowDeletePosts || boardModel.allowDeleteFiles) ? View.VISIBLE : View.GONE);
        
        if (boardModel.allowNames && !boardModel.allowEmails) nameField.setLayoutParams(getWideLayoutParams());
        else if (!boardModel.allowNames && boardModel.allowEmails) emailField.setLayoutParams(getWideLayoutParams());
    }
    
    boolean[] markupEnabled = {
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_QUOTE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_BOLD),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_ITALIC),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_UNDERLINE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_STRIKE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_SPOILER),
    };
    if (markupEnabled[0] || markupEnabled[1] || markupEnabled[2] || markupEnabled[3] || markupEnabled[4] || markupEnabled[5]) {
        markLayout.setVisibility(View.VISIBLE);
        if (!markupEnabled[0]) markLayout.findViewById(R.id.postform_mark_quote).setVisibility(View.GONE);
        if (!markupEnabled[1]) markLayout.findViewById(R.id.postform_mark_bold).setVisibility(View.GONE);
        if (!markupEnabled[2]) markLayout.findViewById(R.id.postform_mark_italic).setVisibility(View.GONE);
        if (!markupEnabled[3]) markLayout.findViewById(R.id.postform_mark_underline).setVisibility(View.GONE);
        if (!markupEnabled[4]) markLayout.findViewById(R.id.postform_mark_strike).setVisibility(View.GONE);
        if (!markupEnabled[5]) markLayout.findViewById(R.id.postform_mark_spoiler).setVisibility(View.GONE);
    } else {
        markLayout.setVisibility(View.GONE);
    }
    
    subjectField.setVisibility(boardModel.allowSubjects ? View.VISIBLE : View.GONE);
    chkboxLayout.setVisibility(boardModel.allowSage || boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    sageChkbox.setVisibility(boardModel.allowSage ? View.VISIBLE : View.GONE);
    custommarkChkbox.setVisibility(boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    if (boardModel.customMarkDescription != null) custommarkChkbox.setText(boardModel.customMarkDescription);
    spinner.setVisibility(boardModel.allowIcons ? View.VISIBLE : View.GONE);
    
    if (boardModel.allowIcons) {
        spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, boardModel.iconDescriptions));
    }
}