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

The following examples show how to use android.widget.Button#setOnClickListener() . 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: LoginActivity.java    From cannonball-android with Apache License 2.0 7 votes vote down vote up
private void setUpPhoneAuthButton() {
    phoneButton = (Button) findViewById(R.id.phone_button);

    phoneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            List<AuthUI.IdpConfig> providers = Arrays.asList(
                    new AuthUI.IdpConfig.PhoneBuilder().build()
            );

            startActivityForResult(
                    AuthUI.getInstance()
                            .createSignInIntentBuilder()
                            .setAvailableProviders(providers)
                            .build(),
                    RC_SIGN_IN
            );
        }
    });
}
 
Example 2
Source File: Registro.java    From android with GNU General Public License v2.0 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registro);

    posicion = getIntent().getIntExtra("posicion", -1);
    if (posicion != -1)
        cargar(posicion);

    Button btGuardar = (Button) findViewById(R.id.btGuardar);
    btGuardar.setOnClickListener(this);
    Button btCancelar = (Button) findViewById(R.id.btCerrar);
    btCancelar.setOnClickListener(this);
    ImageButton ibFoto = (ImageButton) findViewById(R.id.ibFoto);
    ibFoto.setOnClickListener(this);
}
 
Example 3
Source File: AboutActivity.java    From SuperToasts with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final Button button = (Button) findViewById(R.id.github);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final Intent issueIntent = new Intent(Intent.ACTION_VIEW);
            issueIntent.setData(Uri.parse(URL));
            startActivity(issueIntent);
        }
    });
}
 
Example 4
Source File: ResetPasswordDialog.java    From android-login-registration-authentication-client with MIT License 6 votes vote down vote up
private void initViews(View v) {

        mEtEmail = (EditText) v.findViewById(R.id.et_email);
        mEtToken = (EditText) v.findViewById(R.id.et_token);
        mEtPassword = (EditText) v.findViewById(R.id.et_password);
        mBtResetPassword = (Button) v.findViewById(R.id.btn_reset_password);
        mProgressBar = (ProgressBar) v.findViewById(R.id.progress);
        mTvMessage = (TextView) v.findViewById(R.id.tv_message);
        mTiEmail = (TextInputLayout) v.findViewById(R.id.ti_email);
        mTiToken = (TextInputLayout) v.findViewById(R.id.ti_token);
        mTiPassword = (TextInputLayout) v.findViewById(R.id.ti_password);

        mBtResetPassword.setOnClickListener(view -> {
            if (isInit) resetPasswordInit();
            else resetPasswordFinish();
        });
    }
 
Example 5
Source File: SecondFragment.java    From fragments-viewpager-example with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View view = inflater
			.inflate(R.layout.second_fragment, container, false);

	Button btn = (Button) view.findViewById(R.id.btn);

	btn.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			FragmentTransaction trans = getFragmentManager()
					.beginTransaction();
			trans.replace(R.id.root_frame, new StaticFragment());
			trans.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
			trans.addToBackStack(null);
			trans.commit();
		}
	});

	return view;
}
 
Example 6
Source File: SecondActivity.java    From android-advanced-light with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bt_jump= (Button) this.findViewById(R.id.bt_jump);
    bt_jump.setText("发送事件");
    bt_jump.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            OttoBus.getInstance().post(new BusData("刘望舒的博客更新了"));
            finish();
        }
    });
    bus=OttoBus.getInstance();
    bus.register(this);
}
 
Example 7
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final EditText editText = findViewById(R.id.inEmail);
    Button button = findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean isValid = Utils.checkEmailForValidity(editText.getText().toString());

            if (isValid) {
                Toast.makeText(getApplicationContext(), "Email is valid", Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getApplicationContext(), "Email not valid", Toast.LENGTH_LONG).show();
            }
        }
    });
}
 
Example 8
Source File: LoginActivity.java    From retrofit2-oauthrefresh with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    loginButton = (Button) findViewById(R.id.loginButton);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse(API_LOGIN_URL));
            // This flag is set to prevent the browser with the login form from showing in the history stack
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

            startActivity(intent);
            finish();
        }
    });
}
 
Example 9
Source File: FragmentDialog.java    From PreferenceFragment with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_dialog);

    View tv = findViewById(R.id.text);
    ((TextView) tv).setText("Example of displaying dialogs with a DialogFragment.  "
            + "Press the show button below to see the first dialog; pressing "
            + "successive show buttons will display other dialog styles as a "
            + "stack, with dismissing or back going to the previous dialog.");

    // Watch for button clicks.
    Button button = (Button) findViewById(R.id.show);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog();
        }
    });

    if (savedInstanceState != null) {
        mStackLevel = savedInstanceState.getInt("level");
    }
}
 
Example 10
Source File: MainActivity.java    From MediaChooser with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE); 
	setContentView(R.layout.activity_main);
	folderViewButton = (Button)findViewById(R.id.folderButton);
	fileViewButton = (Button)findViewById(R.id.fileButton);
	gridView = (GridView)findViewById(R.id.gridView);
	folderViewButton.setOnClickListener(clickListener);
	fileViewButton.setOnClickListener(clickListener);

	IntentFilter videoIntentFilter = new IntentFilter(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
	registerReceiver(videoBroadcastReceiver, videoIntentFilter);

	IntentFilter imageIntentFilter = new IntentFilter(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
	registerReceiver(imageBroadcastReceiver, imageIntentFilter);

}
 
Example 11
Source File: MainActivity.java    From android-flat-button 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);
    twitterBtn = (FButton) findViewById(R.id.f_twitter_button);
    disabledBtn = (FButton) findViewById(R.id.disabled_button);
    Button changeColorBtn = (Button) findViewById(R.id.change_color_button);
    ToggleButton shadowSwitch = (ToggleButton) findViewById(R.id.enable_shadow_switch);
    shadowHeightBar = (SeekBar) findViewById(R.id.shadow_height_seekbar);
    shadowHeight = (TextView) findViewById(R.id.shadow_height_value);

    changeColorBtn.setOnClickListener(this);
    shadowSwitch.setOnCheckedChangeListener(this);
    shadowHeightBar.setOnSeekBarChangeListener(this);

    //Config disabled button
    disabledBtn.setButtonColor(getResources().getColor(R.color.fbutton_color_concrete));
    disabledBtn.setShadowEnabled(true);
    disabledBtn.setShadowHeight(5);
    disabledBtn.setCornerRadius(5);
}
 
Example 12
Source File: LauncherShortcutConfirmAndGenerateActivity.java    From FreezeYou with Apache License 2.0 6 votes vote down vote up
private void processSimulateButton(final EditText lscaga_package_editText, final EditText lscaga_target_editText, final EditText lscaga_task_editText, final Button lscaga_simulate_button) {
    lscaga_simulate_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String pkgName = lscaga_package_editText.getText().toString();
            String target = lscaga_target_editText.getText().toString();
            String tasks = lscaga_task_editText.getText().toString();
            if (getString(R.string.launch).equals(target))
                target = null;
            startActivity(
                    new Intent(LauncherShortcutConfirmAndGenerateActivity.this, Freeze.class)
                            .putExtra("pkgName", pkgName)
                            .putExtra("target", target)
                            .putExtra("tasks", tasks)
            );
        }
    });
}
 
Example 13
Source File: WelcomeDialog.java    From Torchie-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.dialog_welcome, container, false);
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    but_dismiss = (Button) rootView.findViewById(R.id.but_welcome_dismiss);
    but_dismiss.setOnClickListener(this);
    return rootView;
}
 
Example 14
Source File: MainActivity.java    From opencdk-appwidget with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.layout_main_fm, container, false);

    btnNewsList = (Button) rootView.findViewById(R.id.btn_news_list);
    btnOpenCDKHome = (Button) rootView.findViewById(R.id.btn_opencdk_home);

    btnNewsList.setOnClickListener(this);
    btnOpenCDKHome.setOnClickListener(this);

    return rootView;
}
 
Example 15
Source File: MainActivity.java    From hedera-sdk-java with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EditText privateKey = findViewById(R.id.private_key);
    Button genPrivateKey = findViewById(R.id.gen_private_key);

    genPrivateKey.setOnClickListener(_view -> {
        privateKey.setText(Ed25519PrivateKey.generate().toString());
    });
}
 
Example 16
Source File: ViewAnimationActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.day20_activity_view_animation);
    mButton = (Button) findViewById(R.id.button_animate);

    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            randomAnimation();
        }
    });
}
 
Example 17
Source File: AntiTheftSetupAty.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
private void initViews() {
	
	ivShowAntiTheftStatus = (ImageView)findViewById(R.id.antiTheftStatus);
	ivShowAntiTheftStatus.setOnClickListener(this);
	ivRing = (ImageView)findViewById(R.id.ring);
	ivRing.setOnClickListener(this);
	ivVibrate = (ImageView)findViewById(R.id.vibrate);
	ivVibrate.setOnClickListener(this);
	btnDelay = (Button)findViewById(R.id.delay);
	btnDelay.setOnClickListener(this);
	btnAlarmRingtone = (Button)findViewById(R.id.ringtone);
	btnAlarmRingtone.setOnClickListener(this);
	ivEnhancedMode = (ImageView)findViewById(R.id.enhancedMode);
	ivEnhancedMode.setOnClickListener(this);
	ivBTClosed = (ImageView)findViewById(R.id.bt);
	ivBTClosed.setOnClickListener(this);
	btnRestSensitivity = (Button)findViewById(R.id.sensivity);
	btnRestSensitivity.setOnClickListener(this);
	
	MyUtils.setToogleImageStatus(ivShowAntiTheftStatus, setSP.isAntiTheftShowStatus());
	MyUtils.setToogleImageStatus(ivRing, setSP.isAntiTheftRing());
	MyUtils.setToogleImageStatus(ivVibrate, setSP.isAntiTheftVibrate());
	btnDelay.setText(setSP.getAntiTheftDelayTimeString());
	MyUtils.setToogleImageStatus(ivEnhancedMode, setSP.isAntiTheftOpenBTEnhancedMode());
	MyUtils.setToogleImageStatus(ivBTClosed, setSP.isAntiTheftBTClosedAlarm());
	btnRestSensitivity.setText(setSP.getAntiTheftRestSensitivityString());
}
 
Example 18
Source File: PointCloudActivity.java    From tango with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jpoint_cloud);
    setTitle(R.string.app_name);

    mPoseTextView = (TextView) findViewById(R.id.pose);
    mQuatTextView = (TextView) findViewById(R.id.quat);
    mPoseCountTextView = (TextView) findViewById(R.id.posecount);
    mDeltaTextView = (TextView) findViewById(R.id.deltatime);
    mTangoEventTextView = (TextView) findViewById(R.id.tangoevent);
    mPoseStatusTextView = (TextView) findViewById(R.id.status);
    mPointCountTextView = (TextView) findViewById(R.id.pointCount);
    mTangoServiceVersionTextView = (TextView) findViewById(R.id.version);
    mApplicationVersionTextView = (TextView) findViewById(R.id.appversion);
    mAverageZTextView = (TextView) findViewById(R.id.averageZ);
    mFrequencyTextView = (TextView) findViewById(R.id.frameDelta);

    mSaveButton = (Button) findViewById(R.id.saveButton);
    mSaveButton.setOnClickListener(this);
    mFirstPersonButton = (Button) findViewById(R.id.first_person_button);
    mFirstPersonButton.setOnClickListener(this);
    mThirdPersonButton = (Button) findViewById(R.id.third_person_button);
    mThirdPersonButton.setOnClickListener(this);
    mTopDownButton = (Button) findViewById(R.id.top_down_button);
    mTopDownButton.setOnClickListener(this);

    mGLView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
    mGLView.setEGLContextClientVersion(2);

    mTango = new Tango(this);
    mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT);
    // tangoCameraPreview = (TangoCameraPreview) findViewById(R.id.cameraView);

    int maxDepthPoints = mConfig.getInt("max_point_cloud_elements");
    mRenderer = new PCRenderer(maxDepthPoints);
    mGLView.setRenderer(mRenderer);

    mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
    mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    PackageInfo packageInfo;
    try {
        packageInfo = this.getPackageManager().getPackageInfo(
                this.getPackageName(), 0);
        mApplicationVersionTextView.setText(packageInfo.versionName);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    // Display the version of Tango Service
    mServiceVersion = mConfig.getString("tango_service_library_version");
    mTangoServiceVersionTextView.setText(mServiceVersion);
    mIsTangoServiceConnected = false;

    // Set up OpenGL ES surface
    mCamView = new GLSurfaceView(this);
    mCamView.setEGLContextClientVersion(2);
    mCamView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR);
    mCamView.setRenderer(renderer_ = new FrameRenderer(this));
    mCamView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    mCamView.setOnClickListener(this);
    FrameLayout placeholder = (FrameLayout)findViewById(R.id.cameraFrame);
    placeholder.addView(mCamView);
    cameraTextures_ = new HashMap<>();
}
 
Example 19
Source File: ItsBlogActivity.java    From LoveTalkClient with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.itsblog);

	mContext = ItsBlogActivity.this;

	Intent intent = getIntent();
	lPhone = intent.getStringExtra("ITSPHONE");

	showDate = (TextView) findViewById(R.id.showTime);
	showNumber = (TextView) findViewById(R.id.number);
	showNumberWord = (TextView) findViewById(R.id.numberWord);
	setDate = (Button) findViewById(R.id.setDate);
	list = (ListView) findViewById(R.id.seeBlog);

	//初始化Calendar日历对象
	Calendar mycalendar = Calendar.getInstance(Locale.CHINA);
	Date myDate = new Date(); //获取当前日期Date对象
	mycalendar.setTime(myDate);////为Calendar对象设置时间为当前日期

	year = mycalendar.get(Calendar.YEAR); //获取Calendar对象中的年
	month = mycalendar.get(Calendar.MONTH);//获取Calendar对象中的月
	day = mycalendar.get(Calendar.DAY_OF_MONTH);//获取这个月的第几天
	showDate.setText("当前日志日期:" + year + "-" + (month + 1) + "-" + day); //显示当前的年月日

	//添加单击事件--设置日期
	setDate.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			//创建DatePickerDialog对象
			DatePickerDialog datePickerDialog = new DatePickerDialog(mContext,
					Datelistener, year, month, day);
			datePickerDialog.show();//显示DatePickerDialog组件
		}
	});


	toQuery();
}
 
Example 20
Source File: SubmitOrderActivity.java    From HomeApplianceMall with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_submit_order);
    application = (MyApplication)getApplication();
    resList = (List<Map<String,String>>)getIntent().getSerializableExtra("submitRes");
    getIntent().getFloatExtra("allPrice",2);
    listView = (ListView) findViewById(R.id.listView_submit_order);
    textAllPrice = (TextView) findViewById(R.id.textView_submit_order_all_price);
    btn = (Button) findViewById(R.id.button_submit_order);
    editAdd = (EditText) findViewById(R.id.editText_submit_order_add);
    editAddName = (EditText) findViewById(R.id.editText_submit_order_name);
    editAddTel = (EditText) findViewById(R.id.editText_submit_order_tel);
    textAllPrice.setText("总价:¥"+Float.toString(getIntent().getFloatExtra("allPrice",2)));
    initList();
    myAdapter = new MyAdapterForOrderSubmit(this.getBaseContext(),list);
    listView.setAdapter(myAdapter);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            btn.setEnabled(false);
            String add,addName,addTel;
            add = editAdd.getText().toString();
            addName = editAddName.getText().toString();
            addTel = editAddTel.getText().toString();
            if(addName.length()==0){
                Toast.makeText(SubmitOrderActivity.this,"请填写收货人姓名",Toast.LENGTH_SHORT).show();
                btn.setEnabled(true);
                return;
            }
            if(addTel.length()==0){
                Toast.makeText(SubmitOrderActivity.this,"请填写收货人电话",Toast.LENGTH_SHORT).show();
                btn.setEnabled(true);
                return;
            }
            if(add.length()==0){
                Toast.makeText(SubmitOrderActivity.this,"请填写收货人地址",Toast.LENGTH_SHORT).show();
                btn.setEnabled(true);
                return;
            }
            String[] res = new String[3];
            res[0] = addName ;
            res[1] = addTel ;
            res[2] = add ;
            SubmitOrderAC ac = new SubmitOrderAC();
            if(!ac.isCancelled()){
                ac.execute(res);
            }
        }
    });
    //----------
}