Skip to content

Instantly share code, notes, and snippets.

@emedinaa
Created December 23, 2014 20:35
Show Gist options
  • Save emedinaa/dbbef3d57471e61a2359 to your computer and use it in GitHub Desktop.
Save emedinaa/dbbef3d57471e61a2359 to your computer and use it in GitHub Desktop.
Example Butter Knife
// http://jakewharton.github.io/butterknife/
//activity
public class MyActivity extends Activity
{
@InjectView(R.id.ibuClose) ImageButton ibuClose;
@InjectView(R.id.lviMyAlerts) ListView lviMyAlerts;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.my_activity);
ButterKnife.inject(this);
}
}
//fragments
public class MyFragment extends Fragment
{
@InjectView(R.id.txtUser)
EditText txtUser;
@InjectView(R.id.txtPassword)
EditText txtPassword;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
v = inflater.inflate(R.layout.my_fragment, container, false);
ButterKnife.inject(this, v);
return v;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment