public static void load(Activity a, int R_layout_yourXML) { a.setContentView(R_layout_yourXML); Views.inject(a); // butterknife injection String className = a.getClass().getCanonicalName() + "$$ViewInjector"; try { Log.i(LOG_TAG, "Checking if butterknife injections exist" + ", className=" + className); Class.forName(className); } catch (ClassNotFoundException e) { // injection did not work show instructions: Log.e( LOG_TAG, "! Butterknife could not find injection classes " + "(see http://jakewharton.github.io/" + "butterknife/ide-eclipse.html )"); Log.e( LOG_TAG, "! Right click on project -> " + "Head to Java Compiler -> Annotation " + "Processing -> CHECK 'Enable project " + "specific settings'"); Log.e( LOG_TAG, "! Select 'Factory Path' -> " + "Check \"Enable project specific settings\" " + "-> click \"Add JARs\" -> Navigate to the " + "project's libs/ folder and select " + "the Butter Knife jar -> Click Ok"); throw new RuntimeException( "Butterknife could not " + "find injection class '" + className + "'"); } }
@Override public void setContentView(final int layoutResId) { super.setContentView(layoutResId); // Used to inject views with the Butterknife library Views.inject(this); }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); Injector.inject(this); accountManager = AccountManager.get(this); final Intent intent = getIntent(); email = intent.getStringExtra(PARAM_USERNAME); authTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE); confirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false); requestNewAccount = email == null; setContentView(layout.signup_activity); Views.inject(this); emailText.setAdapter( new ArrayAdapter<String>(this, simple_dropdown_item_1line, userEmailAccounts())); passwordText.setOnKeyListener( new OnKeyListener() { public boolean onKey(final View v, final int keyCode, final KeyEvent event) { if (event != null && ACTION_DOWN == event.getAction() && keyCode == KEYCODE_ENTER && signInButton.isEnabled()) { handleLogin(signInButton); return true; } return false; } }); passwordText.setOnEditorActionListener( new OnEditorActionListener() { public boolean onEditorAction( final TextView v, final int actionId, final KeyEvent event) { if (actionId == IME_ACTION_DONE && signInButton.isEnabled()) { handleLogin(signInButton); return true; } return false; } }); emailText.addTextChangedListener(watcher); passwordText.addTextChangedListener(watcher); final TextView signUpText = (TextView) findViewById(id.tv_signup); signUpText.setMovementMethod(LinkMovementMethod.getInstance()); signUpText.setText(Html.fromHtml(getString(string.signin_link))); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_open_animation, R.anim.activity_close_animation); setTitle(R.string.bluetooth_address_text); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); setContentView(R.layout.activity_bluttooth_address); Views.inject(this); updateConnectedDeviceInformation(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_signin, container, false); Views.inject(this, view); // handle sign in signinBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { handleSignin(); } }); // set hint to textfield phoneNumberTxt.setHint(R.string.label_phone_number); pinNumberTxt.setHint(R.string.label_pin_number); // set phone number if (launchFrom.equals(SmsRegistrationListenerFragment.TAG_NAME)) { // set phone without country code String phone = profileData.getPhone(); String phoneNumber = phone.replace("+" + INDONESIA_COUNTRY_CODE, ""); phoneNumberTxt.setText(phoneNumber); } // add text changed listener phoneNumberTxt.addTextChangedListener(watcher); pinNumberTxt.addTextChangedListener(watcher); // Toolbar initiation initToolbar(); return view; }
@Override public void setContentView(final int layoutResId) { super.setContentView(layoutResId); Views.inject(this); }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.imageselect_activity); Views.inject(this); scaleChoiceIndex = Settings.getLogImageScale(); imageCaption = ""; imageDescription = ""; imageUri = Uri.EMPTY; // Get parameters from intent and basic cache information from database final Bundle extras = getIntent().getExtras(); if (extras != null) { imageCaption = extras.getString(EXTRAS_CAPTION); imageDescription = extras.getString(EXTRAS_DESCRIPTION); imageUri = Uri.parse(extras.getString(EXTRAS_URI_AS_STRING)); scaleChoiceIndex = extras.getInt(EXTRAS_SCALE, scaleChoiceIndex); } // Restore previous state if (savedInstanceState != null) { imageCaption = savedInstanceState.getString(SAVED_STATE_IMAGE_CAPTION); imageDescription = savedInstanceState.getString(SAVED_STATE_IMAGE_DESCRIPTION); imageUri = Uri.parse(savedInstanceState.getString(SAVED_STATE_IMAGE_URI)); scaleChoiceIndex = savedInstanceState.getInt(SAVED_STATE_IMAGE_SCALE); } cameraButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { selectImageFromCamera(); } }); storedButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { selectImageFromStorage(); } }); if (StringUtils.isNotBlank(imageCaption)) { captionView.setText(imageCaption); } if (StringUtils.isNotBlank(imageDescription)) { descriptionView.setText(imageDescription); } scaleView.setSelection(scaleChoiceIndex); scaleView.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { scaleChoiceIndex = scaleView.getSelectedItemPosition(); Settings.setLogImageScale(scaleChoiceIndex); } @Override public void onNothingSelected(AdapterView<?> arg0) {} }); saveButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { saveImageInfo(true); } }); clearButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { saveImageInfo(false); } }); loadImagePreview(); }
@Override protected void onFinishInflate() { super.onFinishInflate(); Views.inject(this); }