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


Java CheckBox.setChecked方法代码示例

本文整理汇总了Java中android.widget.CheckBox.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBox.setChecked方法的具体用法?Java CheckBox.setChecked怎么用?Java CheckBox.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.CheckBox的用法示例。


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

示例1: createView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected View createView(ViewGroup parent) {
    View view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.check_option, parent, false);

    TextView titleText = (TextView) view.findViewById(R.id.preference_check_title);
    final TextView detailText = (TextView) view.findViewById(R.id.preference_check_body);
    final CheckBox toggle = (CheckBox) view.findViewById(R.id.preference_check_toggle);

    titleText.setText(getTitle());
    detailText.setText(getDescription(isToggled()));
    toggle.setChecked(isToggled());

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            toggle.setChecked(!isToggled());
        }
    });

    toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            onSwitchToggle(isChecked);
            detailText.setText(getDescription(isChecked));
        }
    });

    return view;
}
 
开发者ID:marverenic,项目名称:Options,代码行数:31,代码来源:CheckOption.java

示例2: onItemClick

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void onItemClick(View itemView, int position) {
    RequestBean bean = mApps.get(position);
    CheckBox cbCheck = (CheckBox) itemView.findViewById(R.id.cb_check);

    // 反向选择
    cbCheck.setChecked(!bean.isCheck);
    bean.isCheck = !bean.isCheck;

    if (bean.isCheck) {
        mCheckedPositions.add(position);
    } else {
        mCheckedPositions.remove(Integer.valueOf(position));
    }

    handleFabShow();
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:18,代码来源:RequestFragment.java

示例3: OrientationDialog

import android.widget.CheckBox; //导入方法依赖的package包/类
public OrientationDialog(Context context) {
    super(context);
    setTitle("Choose Orientation");
    setContentView(R.layout.orientation_dialog_layout);
    final CheckBox verticalCheckBox = findViewById(R.id.vertical);
    final CheckBox horizontalCheckBox = findViewById(R.id.horizontal);
    verticalCheckBox.setChecked(PreferencesUtil.getInstance().isOrientationVertical());
    horizontalCheckBox.setChecked(PreferencesUtil.getInstance().isOrientationHorizontal());
    findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            PreferencesUtil.getInstance().setOrientationVertical(verticalCheckBox.isChecked());
            PreferencesUtil.getInstance().setOrientationHorizontal(horizontalCheckBox.isChecked());
            UserInactivityUtil.getInstance().onUserInteraction();
            dismiss();
        }
    });
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:19,代码来源:OrientationDialog.java

示例4: getCheckStatus

import android.widget.CheckBox; //导入方法依赖的package包/类
private void getCheckStatus(View view, final int position) {
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
    checkBox.setText(list.get(position));
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView.isChecked()) {
                checkStatus.set(position, true);
            }
            else {
                checkStatus.set(position, false);
            }
        }
    });
    checkBox.setChecked(checkStatus.get(position));
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:17,代码来源:SeatsAdapter.java

示例5: onClick

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    countSelected = position + 1;

    for (int i = 0; i < countNum; i++) {
        CheckBox cb = (CheckBox) getChildAt(i);

        if (i <= position) {
            cb.setChecked(true);
        } else if (i > position) {
            cb.setChecked(false);
        }
    }
    if (mOnRatingChangeListener != null) {
        mOnRatingChangeListener.onChange(countSelected);
    }
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:18,代码来源:XLHRatingBar.java

示例6: getChildView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
    View convertView, ViewGroup parent) {
  if (convertView == null) {
    convertView = inflater.inflate(R.layout.test_loop_item, parent, false);
  }
  CheckBox checkBox = (CheckBox) convertView;
  if (childPosition == 0) {
    boolean allSelected = checkedScenarios.containsAll(getGroup(groupPosition).getLoops());
    checkBox.setChecked(allSelected);
    if (allSelected) {
      checkBox.setText(R.string.unselect_all);
    } else {
      checkBox.setText(R.string.select_all);
    }
  } else {
    Integer item = getChild(groupPosition, childPosition - 1);
    checkBox.setText(String.valueOf(item));
    checkBox.setChecked(checkedScenarios.contains(item));
  }
  return convertView;
}
 
开发者ID:googlesamples,项目名称:testloopmanager,代码行数:23,代码来源:TestLoopGroupAdapter.java

示例7: onClick

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	int id = v.getId();
	switch (id) {
	case R.id.video_choose_cancel:
		finish();
		return;
	case R.id.video_choose_next:
		if (chooseVideo.size() == 0) {
			Toast.makeText(this, "至少选一个", 1).show();
		} else {
			ArrayList<String> videoPaths = new ArrayList<String>();
			for (Map.Entry entry : chooseVideo.entrySet()) {
				videoPaths.add(entry.getValue().toString());
			}
			Intent i = new Intent(this, HoDragVideo.class);
			i.putStringArrayListExtra("videos", videoPaths);
			startActivity(i);
		}
		return;
	default:
		break;
	}
	// TODO Auto-generated method stub
	if (v.getTag() != null && (int) v.getTag() == 1000) {
		Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

		Uri fileUri = getOutputMediaFileUri();
		intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
		intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
		startActivityForResult(intent, 1);
	} else {
		int chkId = 300000 + (int) v.getTag();
		CheckBox chk = (CheckBox) CameraMain2.this.findViewById(chkId);

		chk.setChecked(!chk.isChecked());
		// String videoPath = getPath((int) v.getTag());
		// Intent i = new Intent(CameraMain2.this, VideoPlayer.class);
		// i.putExtra("videoPath", videoPath);
		// i.putExtra("videoButton", (int) v.getTag() + 1000);
		// CameraMain2.this.startActivityForResult(i, 2);
	}
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:44,代码来源:CameraMain2.java

示例8: fillOptions

import android.widget.CheckBox; //导入方法依赖的package包/类
public void fillOptions(final View view, final TGSongManager songManager, final TGSong song, final TGTrack track) {
	CheckBox stringTransposition = (CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose);
	stringTransposition.setChecked(true);
	stringTransposition.setOnCheckedChangeListener(new OnCheckedChangeListener() {
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			onTransposeOptionChanged(view, songManager, song, track);
		}
	});
	((CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose_apply_to_chords)).setChecked(true);
	((CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose_try_keep_strings)).setChecked(true);
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:12,代码来源:TGTrackTuningDialog.java

示例9: getView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    View rowView = view;
    if (rowView == null) {
        LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
        rowView = inflater.inflate(R.layout.task_item, viewGroup, false);
    }

    final Task task = getItem(i);

    TextView titleTV = rowView.findViewById(R.id.title);
    titleTV.setText(task.getTitleForList());

    CheckBox completeCB = rowView.findViewById(R.id.complete);

    // Active/completed task UI
    completeCB.setChecked(task.isCompleted());
    if (task.isCompleted()) {
        rowView.setBackgroundDrawable(viewGroup.getContext()
                .getResources().getDrawable(R.drawable.list_completed_touch_feedback));
    } else {
        rowView.setBackgroundDrawable(viewGroup.getContext()
                .getResources().getDrawable(R.drawable.touch_feedback));
    }

    completeCB.setOnClickListener(__ -> {
        if (!task.isCompleted()) {
            mItemListener.onCompleteTaskClick(task);
        } else {
            mItemListener.onActivateTaskClick(task);
        }
    });

    rowView.setOnClickListener(__ -> mItemListener.onTaskClick(task));

    return rowView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:TasksFragment.java

示例10: getView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.scheduler_task_item, parent, false);
    }

    TextView txtTaskProjectName = (TextView) convertView.findViewById(R.id.txtTaskProjectName);
    TextView txtTaskId = (TextView) convertView.findViewById(R.id.txtTaskId);
    TextView txtTaskType = (TextView) convertView.findViewById(R.id.txtTaskType);
    TextView txtTaskWhen = (TextView) convertView.findViewById(R.id.txtTaskWhen);
    TextView txtTaskInterval = (TextView) convertView.findViewById(R.id.txtTaskInterval);
    CheckBox bRepeating = (CheckBox) convertView.findViewById(R.id.bTaskRepeating);
    CheckBox bWakeUpScreen = (CheckBox) convertView.findViewById(R.id.bTaskWakeUpScreen);

    SchedulerManager.Task task = getItem(position);

    MLog.d(TAG, "ww task loaded " + task.id + " " + txtTaskId);

    txtTaskProjectName.setText(task.project.getSandboxPath());

    txtTaskId.setText("" + task.id);
    txtTaskType.setText("" + task.type);
    txtTaskWhen.setText("" + task.time.getTime());
    txtTaskInterval.setText("" + task.interval);
    bRepeating.setChecked(task.repeating);
    bWakeUpScreen.setChecked(task.wakeUpScreen);

    return convertView;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:31,代码来源:SchedulerActivity.java

示例11: initView

import android.widget.CheckBox; //导入方法依赖的package包/类
private void initView() {
    mRegister = (Button) findViewById(R.id.btn_register);
    mRegister.setOnClickListener(this);
    mUserName = (EditText) findViewById(R.id.user_name);
    mPassword = (EditText) findViewById(R.id.pass);
    mLogin = (Button) findViewById(R.id.btn_login);
    mLogin.setOnClickListener(this);
    mKeepPass = (CheckBox) findViewById(R.id.keep_pass);
    mForgetPassword = (TextView) findViewById(R.id.forget_pass_word);
    mForgetPassword.setOnClickListener(this);

    appLabel = (TextView) findViewById(R.id.label);
    UtilTools.setFont(this, appLabel);
    setAppLabel(appLabel);

    //设置选中状态
    boolean isChecked = ShareUtil.getBoolean(this, StaticClass.KEEP_PASS, false);
    mKeepPass.setChecked(isChecked);
    if (isChecked) {
        //显示用户名和密码
        mUserName.setText(ShareUtil.getString(this, "name", ""));
        mPassword.setText(ShareUtil.getString(this, "password", ""));
        mUserName.setSelection(mUserName.length());
    }

    //        mCustomDialog = new CustomDialog(this, 400, 400, R.layout.dialog_loading, R.style
    //                .Theme_dialog, Gravity.CENTER);

    mProgressDialog = new ProgressDialog(this);
    //屏幕外点击无效
    //mCustomDialog.setCancelable(false);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage("正在登陆......");

    //mProgressBar = (ProgressBar) findViewById(R.id.before_login);


}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:39,代码来源:LoginActivity.java

示例12: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContainer = (RelativeLayout) findViewById(R.id.rl_container);
    mEditTextTitle = (EditText) findViewById(R.id.edit_text_title);
    mEditTextContent = (EditText) findViewById(R.id.edit_text_content);
    mButtonClear = (TextView) findViewById(R.id.text_clear);
    mButtonOK = (TextView) findViewById(R.id.text_ok);
    mCheckBoxSelfStarting = (CheckBox) findViewById(R.id.check_box_self_starting);

    mContainer.setOnClickListener(this);
    mButtonOK.setOnClickListener(this);
    mButtonClear.setOnClickListener(this);
    mCheckBoxSelfStarting.setOnClickListener(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mEditTextContent.setSingleLine(false);
        mEditTextContent.setMaxLines(5);
    }

    mContext = getApplicationContext();
    mSharedPreferences = getSharedPreferences(KEY_SETTING, MODE_PRIVATE);

    mEditTextTitle.setText(mSharedPreferences.getString(KEY_TITLE, ""));
    mEditTextContent.setText(mSharedPreferences.getString(KEY_CONTENT, ""));
    mCheckBoxSelfStarting.setChecked(mSharedPreferences.getBoolean(KEY_SELF_STARTING, false));

    Intent intent = getIntent();
    String action = intent.getAction();
    Bundle extras = intent.getExtras();
    if (Intent.ACTION_SEND.equals(action)) {
        if (extras.containsKey(Intent.EXTRA_TEXT)) {
            mEditTextContent.getText().append("\n").append(extras.getString(Intent.EXTRA_TEXT));
        }
    }
}
 
开发者ID:gooosie,项目名称:TinyNoty,代码行数:39,代码来源:MainActivity.java

示例13: setup

import android.widget.CheckBox; //导入方法依赖的package包/类
private void setup()
{
	DownloadService instance = DownloadServiceImpl.getInstance();

	if (instance == null)
	{
		return;
	}

	equalizerController = instance.getEqualizerController();
	equalizer = equalizerController.getEqualizer();

	initEqualizer();

	final View presetButton = findViewById(R.id.equalizer_preset);
	registerForContextMenu(presetButton);
	presetButton.setOnClickListener(new View.OnClickListener()
	{
		@Override
		public void onClick(View view)
		{
			presetButton.showContextMenu();
		}
	});

	CheckBox enabledCheckBox = (CheckBox) findViewById(R.id.equalizer_enabled);
	enabledCheckBox.setChecked(equalizer.getEnabled());
	enabledCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
	{
		@Override
		public void onCheckedChanged(CompoundButton compoundButton, boolean b)
		{
			setEqualizerEnabled(b);
		}
	});
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:37,代码来源:EqualizerActivity.java

示例14: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.place_details);
    mContext = this;
    mResources = getResources();
    
    mMapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentById(R.id.place_map);
    
    mMapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap map) {
            mMap = map;
            updateUI();
        }
    });
    
    mPlaceId = getIntent().getIntExtra(EXTRA_PLACE_POSITION, -1);
    final VisitableGenerator generator = VisitableGenerator.get(this);
    mPlace = generator.getPlace(mPlaceId);
    mLocation = new Location("");
    mLocation.set(mPlace.getLocation());
    
    mPlaceImageViewFull = (ImageView) findViewById(R.id.place_image_full);
    mPlaceCaption = (TextView) findViewById(R.id.place_caption_full);
    mWebView = (WebView) findViewById(R.id.web_view);
    mBackupEmptyView = (TextView) findViewById(R.id.place_backup_empty_view);
    mIndicator = (ProgressBar) findViewById(R.id.indicator);
    mVisitedCheckBox = (CheckBox) findViewById(R.id.visited_check_box);
    
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mProgressBar.setMax(100);
    
    mWebView.setWebChromeClient(new WebChromeClient() {
        
        @Override
        public void onProgressChanged(WebView webView, int newProgress) {
            if (newProgress == 100) {
                mProgressBar.setVisibility(View.GONE);
            } else {
                mProgressBar.setVisibility(View.VISIBLE);
                mProgressBar.setProgress(newProgress);
            }
        }
    });
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.loadUrl(mPlace.getWikiUrl());
    
    Bitmap bitmap = PictureUtils.decodeBitmapFromResource(getResources(),
            mPlace.getImgResourceId(), 400, 400);
    
    mPlaceImageViewFull.setImageBitmap(bitmap);
    mPlaceCaption.setText(mPlace.getPlaceNameResId());
    this.getSupportActionBar().setTitle(mPlace.getPlaceNameResId());
    
    mVisitedCheckBox.setChecked(mPlace.isVisited());
    mVisitedCheckBox.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            mPlace.setVisited(isChecked);
        }
    });
    
    mConnManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    
    NetworkInfo activeNetwork = mConnManager.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
    
    if (!isConnected) {
        mIndicator.setVisibility(View.INVISIBLE);
        mBackupEmptyView.setText(R.string.empty_placeholder);
    }
}
 
开发者ID:plweegie,项目名称:piast-trail,代码行数:76,代码来源:PlaceDetailsActivity.java

示例15: getView

import android.widget.CheckBox; //导入方法依赖的package包/类
/**
 * @brief Returns the view clicked in the list
 * @param position
 * @param convertView
 * @param parent
 * @return view
 * @details Returns the view clicked in the list, put the connection name, the ip, and the
 * icon star
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {		
	
	   View vi=convertView;
         
	    if(convertView == null) {
	      LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	      vi = inflater.inflate(R.layout.element_user, null);
	    }
	             
	    final Connection user = getList().get(position);
	         		    
        
       final CheckBox iconFav = (CheckBox)vi.findViewById(R.id.checkFav);
       iconFav.setTag(user);    	       
       
       iconFav.setOnCheckedChangeListener(
          new CheckBox.OnCheckedChangeListener() {
            @Override
			public void onCheckedChanged(CompoundButton buttonView,
                                                  boolean isChecked) {
                  if (isChecked){
                	  iconFav.setButtonDrawable(R.drawable.star_ful);
                	  user.setFav(true);	                	  
                	 
                  }
                  else {
                	  iconFav.setButtonDrawable(R.drawable.star_emp);
                	  user.setFav(false);	 
                	  
                  }
                  listFragment.refreshFavorites(user);
              }
          });
       
       //para mantener el estado cuando rota
	    if (user.isFav()){
	    	iconFav.setButtonDrawable(R.drawable.star_ful);
	    	iconFav.setChecked(true);
	    }
	    else{
	    	iconFav.setButtonDrawable(R.drawable.star_emp);
	    }
	         
	    TextView name = (TextView) vi.findViewById(R.id.nameConnection);
	    name.setText(user.getName());
	    
	    TextView ip_view = (TextView) vi.findViewById(R.id.descIP);
	    ip_view.setText(user.getIP());
	    
	       CheckBox iconConnect = (CheckBox)vi.findViewById(R.id.checkConnect);
	       iconConnect.setTag(user);   		    
	 
	    return vi;
	
}
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:66,代码来源:Adapter.java


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