android.widget.ToggleButton Java Examples

The following examples show how to use android.widget.ToggleButton. 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: RecommendTopicPresenter.java    From umeng_community_android with MIT License 6 votes vote down vote up
/**
 * 检测是否登录并执行关注/取消关注操作</br>
 * 
 * @param topic
 * @param toggleButton
 * @param isFollow
 */
public void checkLoginAndExecuteOp(final Topic topic, final ToggleButton toggleButton,
        final boolean isFollow) {
    toggleButton.setClickable(false);
    CommonUtils.checkLoginAndFireCallback(mContext, new SimpleFetchListener<LoginResponse>() {

        @Override
        public void onComplete(LoginResponse response) {
            if (response.errCode != ErrorCode.NO_ERROR) {
                toggleButton.setChecked(!toggleButton.isChecked());
                toggleButton.setClickable(true);
                return;
            }
            if (isFollow) {
                followTopic(topic, toggleButton);
            } else {
                cancelFollowTopic(topic, toggleButton);
            }
        }
    });
}
 
Example #2
Source File: SceneScheduleFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    noScheduleContainer = view.findViewById(R.id.schedule_none_container);
    noScheduleToggle = (ToggleButton) view.findViewById(R.id.schedule_none_container_checkbox);
    noScheduleText = (Version1TextView) view.findViewById(R.id.scheduleNoneText);
    noScheduleTextDescription = (Version1TextView) view.findViewById(R.id.scheduleNoneDescription);
    dividerOne = view.findViewById(R.id.divider);

    weeklyScheduleContainer = view.findViewById(R.id.schedule_weekly_container);
    weeklyScheduleToggle = (ToggleButton) view.findViewById(R.id.schedule_weekly_container_checkbox);
    weeklyScheduleText = (Version1TextView) view.findViewById(R.id.scheduleWeeklyText);
    weeklyScheduleTextDescription = (Version1TextView) view.findViewById(R.id.scheduleWeeklyDescription);
    dividerTwo = view.findViewById(R.id.divider2);
    weeklyScheduleClickableRegion = (RelativeLayout) view.findViewById(R.id.weekly_schedule_clickable_region);

    scheduleAbstractText = (Version1TextView) view.findViewById(R.id.scheduleAbstractText);

    chevronImage = (ImageView) view.findViewById(R.id.chevron);
    scheduleBottomText = (Version1TextView) view.findViewById(R.id.scene_schedule_bottom_text);



    return view;
}
 
Example #3
Source File: IMPopupDialog.java    From opensudoku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    String currentTab = mTabHost.getCurrentTabTag();

    if (currentTab.equals("number")) {
        if (mOnNumberEditListener != null) {
            mOnNumberEditListener.onNumberEdit(0); // 0 as clear
        }
        dismiss();
    } else {
        for (ToggleButton b : mNoteNumberButtons.values()) {
            b.setChecked(false);
            mNoteSelectedNumbers.remove(b.getTag());
        }
    }
}
 
Example #4
Source File: DeviceConfigFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    View onView = view.findViewById(R.id.on_cell);
    View onPartialView = view.findViewById(R.id.on_partial_cell);
    View partialView = view.findViewById(R.id.partial_cell);
    View notParticipatingView = view.findViewById(R.id.not_participating_cell);

    mOnCheck = (ToggleButton) view.findViewById(R.id.on_checkbox);
    mOnPartialCheck = (ToggleButton) view.findViewById(R.id.on_partial_checkbox);
    mPartialCheck = (ToggleButton) view.findViewById(R.id.partial_checkbox);
    mNotParticipatingCheck = (ToggleButton) view.findViewById(R.id.not_participating_checkbox);

    onView.setOnClickListener(this);
    onPartialView.setOnClickListener(this);
    partialView.setOnClickListener(this);
    notParticipatingView.setOnClickListener(this);

    return view;
}
 
Example #5
Source File: ViewUtil.java    From sa-sdk-android with Apache License 2.0 6 votes vote down vote up
static boolean isTrackEvent(View view, boolean isFromUser) {
    if (view instanceof CheckBox) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof RadioButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof ToggleButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof CompoundButton) {
        if (!isFromUser) {
            return false;
        }
    }
    if (view instanceof RatingBar) {
        if (!isFromUser) {
            return false;
        }
    }
    return true;
}
 
Example #6
Source File: QuestionFragment.java    From android-galaxyzoo with GNU General Public License v3.0 6 votes vote down vote up
private void storeAnswer(final String questionId, final String answerId) {
    List<String> checkboxes = null;

    //Get the selected checkboxes too:
    final DecisionTree tree = getDecisionTree();
    final DecisionTree.Question question = tree.getQuestion(questionId);
    if ((question != null) && question.hasCheckboxes()) {
        checkboxes = new ArrayList<>();
        for (final DecisionTree.Checkbox checkbox : question.getCheckboxes()) {
            final String checkboxId = checkbox.getId();
            final ToggleButton button = mCheckboxButtons.get(checkboxId);
            if ((button != null) && button.isChecked()) {
                checkboxes.add(checkboxId);
            }
        }
    }

    //Remember the answer:
    mClassificationInProgress.add(questionId, answerId, checkboxes);
}
 
Example #7
Source File: AlarmTopCardItemView.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
public AlarmTopCardItemView(View view) {
    super(view);
    context = view.getContext();
    mDashedCircleView = (DashedCircleView) view.findViewById(R.id.dashed_circle);

    mCenterTopTextView = (Version1TextView) view.findViewById(R.id.center_top_text);
    mCenterBottomTextView = (Version1TextView) view.findViewById(R.id.center_bottom_text);

    mTopIconView = (ImageView) view.findViewById(R.id.top_icon);
    mTopLineView = view.findViewById(R.id.top_line);
    mLeftAlarmIcon = (ImageView) view.findViewById(R.id.left_alarm_icon);
    mCenterAlarmText = (Version1TextView) view.findViewById(R.id.center_alarm_text);
    mRightAlarmIcon = (ImageView) view.findViewById(R.id.right_alarm_icon);
    placeName = (Version1TextView) view.findViewById(R.id.place_name);
    placeAddress = (Version1TextView) view.findViewById(R.id.place_address);
    cardView = (CardView) view.findViewById(R.id.cardView);
    placeLayout = view.findViewById(R.id.place_layout);
    topDivider = view.findViewById(R.id.topdivider);
    careOnOffView = view.findViewById(R.id.care_on_off_toggle_container);
    toggleButton = (ToggleButton) view.findViewById(R.id.care_on_off_toggle);
}
 
Example #8
Source File: RecordShowActivity.java    From RecordPath3D with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.recorddisplay_activity);
	mMapView = (MapView) findViewById(R.id.map);
	mMapView.onCreate(savedInstanceState);// 此方法必须重写
	mGraspRadioButton = (RadioButton) findViewById(R.id.record_show_activity_grasp_radio_button);
	mOriginRadioButton = (RadioButton) findViewById(R.id.record_show_activity_origin_radio_button);
	mOriginRadioButton.setOnClickListener(this);
	mGraspRadioButton.setOnClickListener(this);
	mDisplaybtn = (ToggleButton) findViewById(R.id.displaybtn);
	mDisplaybtn.setOnClickListener(this);
	Intent recordIntent = getIntent();
	int threadPoolSize = Runtime.getRuntime().availableProcessors() * 2 + 3;
	mThreadPool = Executors.newFixedThreadPool(threadPoolSize);
	if (recordIntent != null) {
		mRecordItemId = recordIntent.getIntExtra(RecordActivity.RECORD_ID,
				-1);
	}
	initMap();
}
 
Example #9
Source File: MouseFragment.java    From WirelessHid with Apache License 2.0 6 votes vote down vote up
private void updateSpeed(int newSpeed) {
    // note: we assume at least button have proper speed-tag so this will
    // check what it should

    mSpeed = newSpeed;

    ViewGroup bar = (ViewGroup) getView().findViewById(R.id.speed_control);
    int count = bar.getChildCount();

    for (int i = 0; i < count; i++) {
        View child = bar.getChildAt(i);

        try {
            ToggleButton button = (ToggleButton) child;

            int speed = Integer.parseInt((String) button.getTag());

            button.setChecked(speed == newSpeed);
        } catch (ClassCastException e) {
            // not a button :)
        }
    }
}
 
Example #10
Source File: MainActivity.java    From AnySound2BT with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	ctx = getApplicationContext();
	this.registerReceiver(receiver, filter1);
	this.registerReceiver(receiver, filter2);
	tb1 = (ToggleButton)findViewById(R.id.toggleButton1); 
	audioM = (AudioManager) getApplicationContext().getSystemService(getApplicationContext().AUDIO_SERVICE);
	bMgr =  (BluetoothManager) getApplicationContext().getSystemService(getApplicationContext().BLUETOOTH_SERVICE);

	ImageView img = (ImageView)findViewById(R.id.image1);
	img.setOnClickListener(new View.OnClickListener(){
		public void onClick(View v){
			Intent intent = new Intent();
			intent.setAction(Intent.ACTION_VIEW);
			intent.addCategory(Intent.CATEGORY_BROWSABLE);
			intent.setData(Uri.parse("https://github.com/sauravpradhan/"));
			startActivity(intent);
		}
	});
	   btAdapter = BluetoothAdapter.getDefaultAdapter();
	   devices = btAdapter.getBondedDevices();  
          //Toast.makeText(getApplicationContext(),"No Of BT devices paired is:"+devices.size(),Toast.LENGTH_SHORT).show();
}
 
Example #11
Source File: RecommendTopicFragment.java    From umeng_community_android with MIT License 6 votes vote down vote up
protected void initAdapter() {
    RecommendTopicAdapter adapter = new RecommendTopicAdapter(getActivity());
    adapter.setFromFindPage(!mSaveButtonVisiable);
    mAdapter = adapter;
    adapter.setFollowListener(new FollowListener<Topic>() {

        @Override
        public void onFollowOrUnFollow(Topic topic, ToggleButton toggleButton,
                boolean isFollow) {
            if (isFollow) {
                mPresenter.followTopic(topic, toggleButton);
            } else {
                mPresenter.cancelFollowTopic(topic, toggleButton);
            }
        }
    });
    mTopicListView.setAdapter(mAdapter);
}
 
Example #12
Source File: ToggleButtonActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	// Get a reference to a background container 
	final LinearLayout bg = (LinearLayout) findViewById(R.id.linearlayout);
	
	// Get a reference to the ToggleButton
	final ToggleButton button = (ToggleButton) findViewById(R.id.togglebutton);
	
	// Set an OnClickListener on the ToggleButton
	button.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			
			// Toggle the Background color between a light and dark color
			if (button.isChecked()) {
				bg.setBackgroundColor(0xFFF3F3F3);
			} else {
				bg.setBackgroundColor(0xFF000000);
			}
		}
	});
	
}
 
Example #13
Source File: TimeView.java    From Viewer with Apache License 2.0 6 votes vote down vote up
private void initView() {
    mTimeZone = (View)findViewById(R.id.time_zone);
    mWeekZone = (View)findViewById(R.id.week_zone);
    mSenZone = (View)findViewById(R.id.sen_zone);
    sDataText = (TextView) findViewById(R.id.show_start_time_txt);
    eDataText = (TextView)findViewById(R.id.show_end_time_txt);
    mSensit = (TextView) findViewById(R.id.sensit);
    mOpenBtn1 = (com.zhongyun.viewer.widget.ToggleButton) findViewById(R.id.open_btn1);
    mSunBtn1 = (ToggleButton) findViewById(R.id.sun_btn);
    mMonBtn1 = (ToggleButton) findViewById(R.id.mon_btn);
    mTueBtn1 = (ToggleButton) findViewById(R.id.tue_btn);
    mWedBtn1 = (ToggleButton) findViewById(R.id.wed_btn);
    mThuBtn1 = (ToggleButton) findViewById(R.id.thu_btn);
    mFriBtn1 = (ToggleButton) findViewById(R.id.fri_btn);
    mSatBtn1 = (ToggleButton) findViewById(R.id.sat_btn);
    
    mSwitchText = (TextView)findViewById(R.id.text_switch);

}
 
Example #14
Source File: MainActivity.java    From BesselChart with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        chart = (BesselChart) findViewById(R.id.chart);
        button = (ToggleButton) findViewById(R.id.toggle_btn);
        button.setOnCheckedChangeListener(this);
        // startActivity(new Intent(this, CubicActivity.class));
        // chart.getStyle().setGridColor(Color.parseColor("#66CCCCCC"));
        // chart.setData(getChartData(true));
        // chart.setVelocityX(1.2f);
        chart.setSmoothness(0.4f);
        chart.setChartListener(this);
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
//                chart.setData(getChartData(true));
                getSeriesList(true);
                // chart.setDrawBesselPoint(true);
                chart.setSmoothness(0.33f);
            }
        }, 1000);
    }
 
Example #15
Source File: AlarmActivity.java    From Amadeus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm);
    settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    alarmTimePicker = (TimePicker) findViewById(R.id.alarmTimePicker);
    alarmToggle = (ToggleButton) findViewById(R.id.alarmToggle);
    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    pendingIntent = PendingIntent.getBroadcast(this, Alarm.ALARM_ID, new Intent(this, AlarmReceiver.class), PendingIntent.FLAG_CANCEL_CURRENT);

    alarmTimePicker.setIs24HourView(settings.getBoolean("24-hour_format", true));

    if (settings.getBoolean("alarm_toggle", false)) {
        alarmToggle.setChecked(true);
    } else {
        alarmToggle.setChecked(false);
    }
}
 
Example #16
Source File: IMPopupDialog.java    From opensudoku with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Updates selected numbers in note.
 *
 * @param numbers
 */
public void updateNote(Collection<Integer> numbers) {
    mNoteSelectedNumbers = new HashSet<>();

    if (numbers != null) {
        mNoteSelectedNumbers.addAll(numbers);
    }

    ToggleButton toggleButton;
    for (Integer number : mNoteNumberButtons.keySet()) {
        toggleButton = mNoteNumberButtons.get(number);
        toggleButton.setChecked(mNoteSelectedNumbers.contains(number));
        if (toggleButton.isChecked()) {
            ThemeUtils.applyIMButtonStateToView(toggleButton, ThemeUtils.IMButtonStyle.ACCENT);
        }
    }
}
 
Example #17
Source File: MeUltrasonic.java    From Makeblock-App-For-Android with MIT License 6 votes vote down vote up
public void setEnable(Handler handler){
	mHandler = handler;
	toggleBt = (ToggleButton)view.findViewById(R.id.autoSwitch);
	OnCheckedChangeListener listener = new OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
			isAuto = arg1;
			if(isAuto == true){
				mLoopHandler.postDelayed(mRunnable,100);
			}else{
				byte[] wr = buildWrite(DEV_DCMOTOR, PORT_M1, slot, 0);
				mHandler.obtainMessage(MSG_VALUECHANGED,wr).sendToTarget();
				byte[] wr2 = buildWrite(DEV_DCMOTOR, PORT_M2, slot, 0);
				mHandler.obtainMessage(MSG_VALUECHANGED,wr2).sendToTarget();
			}
		}
	};
	toggleBt.setOnCheckedChangeListener(listener);
}
 
Example #18
Source File: MainActivity.java    From android-apps with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
			
	tb1 = (ToggleButton) findViewById(R.id.number_one);
	tb2 = (ToggleButton) findViewById(R.id.number_two);
	tb3 = (ToggleButton) findViewById(R.id.number_three);
	tb4 = (ToggleButton) findViewById(R.id.number_four);
	tb5 = (ToggleButton) findViewById(R.id.number_five);
	
	tb1.setOnClickListener(this);
	tb2.setOnClickListener(this);
	tb3.setOnClickListener(this);
	tb4.setOnClickListener(this);
	tb5.setOnClickListener(this);
	
}
 
Example #19
Source File: ToggleButtonStyler.java    From dynamico with Apache License 2.0 6 votes vote down vote up
@Override
public View style(View view, JSONObject attributes) throws Exception {
    super.style(view, attributes);

    ToggleButton toggleButton = (ToggleButton) view;

    if(attributes.has("textOn")) {
        toggleButton.setTextOn(attributes.getString("textOn"));
    }

    if(attributes.has("textOff")) {
        toggleButton.setTextOn(attributes.getString("textOff"));
    }

    return toggleButton;
}
 
Example #20
Source File: MainActivity.java    From Android-Dev-Box with Apache License 2.0 6 votes vote down vote up
public void addListenerOnButtonClick(){
    //Getting the ToggleButton and Button instance from the layout xml file
    toggleButton1=(ToggleButton)findViewById(R.id.toggleButton);
    toggleButton2=(ToggleButton)findViewById(R.id.toggleButton2);
    buttonSubmit=(Button)findViewById(R.id.button);

    //Performing action on button click
    buttonSubmit.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View view) {
            StringBuilder result = new StringBuilder();
            result.append("ToggleButton1 : ").
                    append(toggleButton1.getText());
            result.append("\nToggleButton2 : ").
                    append(toggleButton2.getText());
            //Displaying the message in toast
            Toast.makeText(getApplicationContext(),
                    result.toString(), LENGTH_LONG).show();
        }

    });

}
 
Example #21
Source File: MainActivity.java    From BrokenView with MIT License 6 votes vote down vote up
private void initToggleButton(){
    ToggleButton effectBtn = (ToggleButton) findViewById(R.id.toggle_effect);
    ToggleButton callbackBtn = (ToggleButton) findViewById(R.id.toggle_callback);
    final BrokenCallback callback = new MyCallBack();
    CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isOpen) {
            switch (buttonView.getId()) {
                case R.id.toggle_effect:
                    effectEnable = isOpen;
                    break;
                case R.id.toggle_callback:
                    mBrokenView.setCallback(isOpen ? callback : null);
                    break;
            }
        }
    };
    effectBtn.setOnCheckedChangeListener(listener);
    callbackBtn.setOnCheckedChangeListener(listener);
}
 
Example #22
Source File: PandroidCompatViewFactory.java    From pandroid with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressLint("RestrictedApi")
public View onCreateView(String name, Context context, AttributeSet attrs) {
    final Resources.Theme theme = context.getTheme();
    switch (name) {
        case "Button":
            return new PandroidCompatButton(new ContextThemeWrapper(context, theme), attrs);
        case "EditText":
            return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
        case "RadioButton":
            return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
        case "Switch":
            return new PandroidCompatSwitch(new ContextThemeWrapper(context, theme), attrs);
        case "TextView":
            return new PandroidCompatTextView(new ContextThemeWrapper(context, theme), attrs);
        case "ToggleButton":
            return new ToggleButton(new ContextThemeWrapper(context, theme), attrs);
        default:
            return null;
    }
}
 
Example #23
Source File: OnCheckedChangedTest.java    From butterknife with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
@Test public void simple() {
  View tree = ViewTree.create(ToggleButton.class, 1);
  View view1 = tree.findViewById(1);

  Simple target = new Simple();
  Unbinder unbinder = ButterKnife.bind(target, tree);
  assertEquals(0, target.clicks);

  view1.performClick();
  assertEquals(1, target.clicks);

  unbinder.unbind();
  view1.performClick();
  assertEquals(1, target.clicks);
}
 
Example #24
Source File: PacketListActivity.java    From sniffer154 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	AppSniffer154 app;
	
	super.onCreate(savedInstanceState);
	app = (AppSniffer154) getApplication();
	
	app.checkForSnifferAttachedAction(getIntent());
		
	setContentView(R.layout.packet_list);
	findViewById(R.id.toggleCapture).setOnClickListener(this);
	findViewById(R.id.toggleFilter).setOnClickListener(this);
	checkButtonAutoscroll = (CheckBox) findViewById(R.id.checkBoxAutoScroll);
	checkButtonAutoscroll.setChecked(true);
	checkButtonAutoscroll
			.setOnCheckedChangeListener(new AutoscrollOnCheckedChangeListener());
	toggleFiltering = (ToggleButton) findViewById(R.id.toggleFilter);
	// be notified when the current session changes
	sessionContentObserver = new SessionContentObserver(new Handler());

	// set up the packet list
	listViewPacket = (ListView) findViewById(R.id.listViewPacket);
	listViewPacket
			.setOnItemClickListener(new PacketListViewOnItemClickListener());
	setUpCursorLoader();
}
 
Example #25
Source File: Solo.java    From AndroidRipper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Checks if a ToggleButton matching the specified index is checked.
 *
 * @param index of the {@link ToggleButton} to check. {@code 0} if only one is available
 * @return {@code true} if {@link ToggleButton} is checked and {@code false} if it is not checked
 */

public boolean isToggleButtonChecked(int index)
{
	if(config.commandLogging){
		Log.d(config.commandLoggingTag, "isToggleButtonChecked("+index+")");
	}
	
	return checker.isButtonChecked(ToggleButton.class, index);
}
 
Example #26
Source File: HintFragment.java    From android-crackme-challenge with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_hint, container, false);
    final ToggleButton switchShowHint = (ToggleButton) view.findViewById(R.id.switch_show_hint);
    switchShowHint.setOnCheckedChangeListener(new HintFragmentOnCheckedChangeListener((TextView) view.findViewById(R.id.text_hint)));
    return view;
}
 
Example #27
Source File: CreateNewUserActivity.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_new_user);

    getActionBar().hide();

    this.maleButton = (ToggleButton) findViewById(R.id.cnu_maleButton);
    this.femaleButton = (ToggleButton) findViewById(R.id.cnu_femaleButton);
    this.maleButton.setOnClickListener(this);
    this.femaleButton.setOnClickListener(this);
    this.birthDay = (EditText) findViewById(R.id.cnu_birthday);
    this.birthDay.setOnClickListener(this);
    this.birthDay.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                displayDatePicker();
            }
        }
    });

    this.name = (EditText) findViewById(R.id.cnu_name);
    MyTextWatcher textWatcher = new MyTextWatcher();
    this.name.addTextChangedListener(textWatcher);

    this.email = (EditText) findViewById(R.id.cnu_email);
    this.username = (EditText) findViewById(R.id.cnu_username);
    this.username.addTextChangedListener(textWatcher);

    this.password = (EditText) findViewById(R.id.cnu_password);
    this.password.addTextChangedListener(textWatcher);

    this.about = (EditText) findViewById(R.id.cnu_about);
    this.registerButton = (Button) findViewById(R.id.cnu_register);
    this.registerButton.setOnClickListener(this);
}
 
Example #28
Source File: MainActivity.java    From RecordPath3D with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化AMap对象
 */
private void init() {
	if (mAMap == null) {
		mAMap = mMapView.getMap();
		setUpMap();
	}
	btn = (ToggleButton) findViewById(R.id.locationbtn);
	btn.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			if (btn.isChecked()) {
				Log.i("MY", "isChecked");

				mAMap.clear(true);
				if (record != null) {
					record = null;
				}
				record = new PathRecord();
				mStartTime = System.currentTimeMillis();
				record.setDate(getcueDate(mStartTime));
			} else {
				mEndTime = System.currentTimeMillis();
				saveRecord(record.getPathline(), record.getDate());
			}
		}
	});

}
 
Example #29
Source File: HintFragment.java    From android-crackme-challenge with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_hint, container, false);
    final ToggleButton switchShowHint = (ToggleButton) view.findViewById(R.id.switch_show_hint);
    switchShowHint.setOnCheckedChangeListener(new HintFragmentOnCheckedChangeListener((TextView) view.findViewById(R.id.text_hint)));
    return view;
}
 
Example #30
Source File: Solo.java    From AndroidRipper with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Checks if a ToggleButton displaying the specified text is checked.
 *
 * @param text the text that the {@link ToggleButton} displays, specified as a regular expression
 * @return {@code true} if a {@link ToggleButton} matching the specified text is checked and {@code false} if it is not checked
 */

public boolean isToggleButtonChecked(String text)
{
	if(config.commandLogging){
		Log.d(config.commandLoggingTag, "isToggleButtonChecked(\""+text+"\")");
	}
	
	return checker.isButtonChecked(ToggleButton.class, text);
}