setOnClickListener ( )源码实例Demo

android.widget.Button#setOnClickListener ( )源码实例Demo

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

源代码1 项目: cannonball-android   文件: LoginActivity.java
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
            );
        }
    });
}
 
源代码2 项目: SuperToasts   文件: AboutActivity.java
@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);
        }
    });
}
 
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();
        });
    }
 
@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;
}
 
源代码5 项目: android-advanced-light   文件: SecondActivity.java
@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);
}
 
源代码6 项目: android   文件: Registro.java
@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);
}
 
源代码7 项目: PreferenceFragment   文件: FragmentDialog.java
@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");
    }
}
 
源代码8 项目: android-flat-button   文件: MainActivity.java
@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);
}
 
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)
            );
        }
    });
}
 
源代码10 项目: MediaChooser   文件: MainActivity.java
@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);

}
 
源代码11 项目: retrofit2-oauthrefresh   文件: LoginActivity.java
@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();
        }
    });
}
 
源代码12 项目: journaldev   文件: MainActivity.java
@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();
            }
        }
    });
}
 
源代码13 项目: Huochexing12306   文件: AntiTheftSetupAty.java
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());
}
 
@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();
        }
    });
}
 
源代码15 项目: hedera-sdk-java   文件: MainActivity.java
@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());
    });
}
 
源代码16 项目: opencdk-appwidget   文件: MainActivity.java
@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;
}
 
源代码17 项目: Torchie-Android   文件: WelcomeDialog.java
@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;
}
 
源代码18 项目: HomeApplianceMall   文件: SubmitOrderActivity.java
@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);
            }
        }
    });
    //----------
}
 
源代码19 项目: tango   文件: PointCloudActivity.java
@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<>();
}
 
源代码20 项目: LoveTalkClient   文件: ItsBlogActivity.java
@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();
}