本文整理匯總了Java中android.widget.Switch.setOnClickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Switch.setOnClickListener方法的具體用法?Java Switch.setOnClickListener怎麽用?Java Switch.setOnClickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.Switch
的用法示例。
在下文中一共展示了Switch.setOnClickListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initView
import android.widget.Switch; //導入方法依賴的package包/類
private void initView()
{
switch_voice= (Switch) findViewById(R.id.switch_voice);
switch_sms= (Switch) findViewById(R.id.switch_sms);
ll_check_version= (LinearLayout) findViewById(R.id.ll_check_version);
tv_version_name= (TextView) findViewById(R.id.tv_version_name);
ll_scan_qrcode= (LinearLayout) findViewById(R.id.ll_scan_qrcode);
ll_my_qrcode= (LinearLayout) findViewById(R.id.ll_my_qrcode);
ll_location= (LinearLayout) findViewById(R.id.ll_location);
//獲取當前版本信息顯示在界麵上
showCurrentVersionInfo();
//為各種開關設置監聽事件
switch_voice.setOnClickListener(this);
switch_sms.setOnClickListener(this);
ll_check_version.setOnClickListener(this);
ll_scan_qrcode.setOnClickListener(this);
ll_my_qrcode.setOnClickListener(this);
ll_location.setOnClickListener(this);
//進入界麵後讀取之前保存的開關狀態
switch_voice.setChecked(SharedUtils.getBoolean("voice_key",false));
switch_sms.setChecked(SharedUtils.getBoolean("sms_key",false));
}
示例2: getView
import android.widget.Switch; //導入方法依賴的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.list_item_notification, null, true);
final NotificationSetting notification = notifications.get(position);
final Switch notificationSwitch = (Switch) rowView.findViewById(R.id.notificationSwitch);
final TextView notificationTextView = (TextView) rowView.findViewById(R.id.notificationTextView);
notificationSwitch.setChecked(notification.isEnabled());
notificationTextView.setText(notification.getTime());
if (!notification.isEnabled()) {
notificationTextView.setTextColor(Color.GRAY);
}
notificationSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notification.setEnabled(notificationSwitch.isChecked());
if (notificationSwitch.isChecked()) {
notificationTextView.setTextColor(Color.BLACK);
} else {
notificationTextView.setTextColor(Color.GRAY);
}
parentActivity.updateChanges(notifications);
}
});
return rowView;
}
示例3: initView
import android.widget.Switch; //導入方法依賴的package包/類
private void initView() {
//是否語音
mSwSpeack = (Switch) findViewById(R.id.sw_speak);
boolean isSpeak = ShareUtil.getBoolean(this, "isSpeak", false);
mSwSpeack.setChecked(isSpeak);
mSwSpeack.setOnClickListener(this);
//是否短信
mSwSms = (Switch) findViewById(R.id.sw_sms);
boolean isSms = ShareUtil.getBoolean(this, "isSms", false);
mSwSms.setChecked(isSms);
mSwSms.setOnClickListener(this);
//檢查版本
mUpdate = (LinearLayout) findViewById(R.id.ll_update);
mUpdate.setOnClickListener(this);
mTvVersion = (TextView) findViewById(R.id.tv_version);
try {
getVersionNameAndCode();
mTvVersion.setText(String.format("當前版本:%s", versionName));
} catch (PackageManager.NameNotFoundException e) {
mTvVersion.setText("無法獲取當前版本,請檢查網絡");
}
//掃一掃
mQrcodeScan = (LinearLayout) findViewById(R.id.qrcode_scan);
mQrcodeScan.setOnClickListener(this);
mScanResult = (TextView) findViewById(R.id.tv_scan_result);
//生成二維碼
mQrcodeShare = (LinearLayout) findViewById(R.id.qrcode_share);
mQrcodeShare.setOnClickListener(this);
//我的位置
mMyLocation = (LinearLayout) findViewById(R.id.my_location);
mMyLocation.setOnClickListener(this);
}
示例4: setBoxes
import android.widget.Switch; //導入方法依賴的package包/類
private void setBoxes() {
Switch box1= (Switch) findViewById(R.id.prefs_autodel_box);
Switch box2= (Switch) findViewById(R.id.prefs_askenc_box);
Switch box3= (Switch) findViewById(R.id.prefs_savepass_box);
box1.setChecked(SharedData.ASK_DEL_AFTER_ENCRYPTION);
box2.setChecked(SharedData.ASK_ENCRYPTION_CONFIG);
box3.setChecked(SharedData.ASK_KEY_PASSS_CONFIG);
box1.setOnClickListener(this);
box2.setOnClickListener(this);
box3.setOnClickListener(this);
}
示例5: onCreate
import android.widget.Switch; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_additive_animations_showcase);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
// load default fragment = tap to move
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new TapToMoveDemoFragment()).commit();
Switch additiveEnabledSwitch = (Switch) findViewById(R.id.additive_animations_enabled_switch);
additiveEnabledSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ADDITIVE_ANIMATIONS_ENABLED = ((Switch)v).isChecked();
}
});
// set the default duration for all animations:
AdditiveAnimator.setDefaultDuration(1000);
}
開發者ID:wirecube,項目名稱:android_additive_animations,代碼行數:30,代碼來源:AdditiveAnimationsShowcaseActivity.java
示例6: initView
import android.widget.Switch; //導入方法依賴的package包/類
private void initView() {
sw_speak = (Switch) findViewById(R.id.sw_speak);
sw_speak.setOnClickListener(this);
boolean isSpeak = getBoolean(this, "isSpeak", false);
sw_speak.setChecked(isSpeak);
sw_sms = (Switch) findViewById(R.id.sw_sms);
sw_sms.setOnClickListener(this);
boolean isSms = ShareUtil.getBoolean(this, "isSms", false);
sw_sms.setChecked(isSms);
tv_version = (TextView) findViewById(R.id.tv_version);
try {
getVersionNameCode();
tv_version.setText(getString(R.string.text_test_version) + versionName);
} catch (PackageManager.NameNotFoundException e) {
tv_version.setText(getString(R.string.text_test_version) );
}
ll_scan = (LinearLayout) findViewById(R.id.ll_scan);
ll_scan.setOnClickListener(this);
tv_scan_result = (TextView) findViewById(R.id.tv_scan_result);
ll_qr_code = (LinearLayout) findViewById(R.id.ll_qr_code);
ll_qr_code.setOnClickListener(this);
ll_about = (LinearLayout) findViewById(R.id.ll_about);
ll_about.setOnClickListener(this);
ll_update = (LinearLayout) findViewById(R.id.ll_update);
ll_update.setOnClickListener(this);
}