demo/src/com/socialize/demo/snippets/LikeButtonSnippets.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
		
	// Define/obtain your entity
	Entity entity = Entity.newInstance("http://getsocialize.com", "Socialize");
	
	// Get a reference to the button you want to transform
	// This can be any type of CompoundButton (CheckBox, RadioButton, Switch, ToggleButton)
	
	CheckBox btnCustomCheckBoxLike = (CheckBox) findViewById(R.id.btnCustomCheckBoxLike);
	
	// Make the button a socialize like button!
	LikeUtils.makeLikeButton(this, btnCustomCheckBoxLike, entity, new LikeButtonListener() {
	
		@Override
		public void onClick(CompoundButton button) {
			// You can use this callback to set any loading text or display a progress dialog
			button.setText("--");
		}
	
		@Override
		public void onCheckedChanged(CompoundButton button, boolean isChecked) {
			// The like was posted successfully, change the button to reflect the change
			if(isChecked) {
				button.setText("Unlike");
			}
			else {
				button.setText("Like");
			}
		}
	
		@Override
		public void onError(CompoundButton button, Exception error) {
			// An error occurred posting the like, we need to return the button to its original state
			Log.e("Socialize", "Error on like button", error);
			if(button.isChecked()) {
				button.setText("Unlike");
			}
			else {
				button.setText("Like");
			}
		}
	});		
}
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
		
	// Define/obtain your entity
	Entity entity = Entity.newInstance("http://getsocialize.com", "Socialize");
	
	// Get a reference to the button you want to transform
	// This can be any type of CompoundButton (CheckBox, RadioButton, Switch, ToggleButton)
	
	CheckBox btnCustomCheckBoxLike = (CheckBox) findViewById(R.id.btnCustomCheckBoxLike);
	
	// Make the button a socialize like button!
	LikeUtils.makeLikeButton(this, btnCustomCheckBoxLike, entity, new LikeButtonListener() {
	
		@Override
		public void onClick(CompoundButton button) {
			// You can use this callback to set any loading text or display a progress dialog
			button.setText("--");
		}
	
		@Override
		public void onCheckedChanged(CompoundButton button, boolean isChecked) {
			// The like was posted successfully, change the button to reflect the change
			if(isChecked) {
				button.setText("Unlike");
			}
			else {
				button.setText("Like");
			}
		}
	
		@Override
		public void onError(CompoundButton button, Exception error) {
			// An error occurred posting the like, we need to return the button to its original state
			Log.e("Socialize", "Error on like button", error);
			if(button.isChecked()) {
				button.setText("Unlike");
			}
			else {
				button.setText("Like");
			}
		}
	});		
}
@ Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; // Define/obtain your entity Entity entity = Entity . newInstance ( "http://getsocialize.com" , "Socialize" ) ; // Get a reference to the button you want to transform // This can be any type of CompoundButton (CheckBox, RadioButton, Switch, ToggleButton) CheckBox btnCustomCheckBoxLike = ( CheckBox ) findViewById ( R . id . btnCustomCheckBoxLike ) ; // Make the button a socialize like button! LikeUtils . makeLikeButton ( this , btnCustomCheckBoxLike , entity , new LikeButtonListener ( ) { @ Override public void onClick ( CompoundButton button ) { // You can use this callback to set any loading text or display a progress dialog button . setText ( "--" ) ; } @ Override public void onCheckedChanged ( CompoundButton button , boolean isChecked ) { // The like was posted successfully, change the button to reflect the change if ( isChecked ) { button . setText ( "Unlike" ) ; } else { button . setText ( "Like" ) ; } } @ Override public void onError ( CompoundButton button , Exception error ) { // An error occurred posting the like, we need to return the button to its original state Log . e ( "Socialize" , "Error on like button" , error ) ; if ( button . isChecked ( ) ) { button . setText ( "Unlike" ) ; } else { button . setText ( "Like" ) ; } } } ) ; }
begin-snippet-0
begin - snippet - 0