31 Dec 2014

ActionSheet like IOS in Android

Hello Friends,

Here is the tutorial for Action Sheet like IOS in Android

OUTPUT SCREEN :




MainActivity :


import com.hb.actionsheet.R;
import com.hb.actionsheet.ActionSheet.ActionSheetListener;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends FragmentActivity implements ActionSheetListener
{
       @Override
       protected void onCreate(Bundle savedInstanceState)
       {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
       }

       public void onClick(View v)
       {
              switch (v.getId())
              {
              case R.id.ios6:
                     setTheme(R.style.ActionSheetStyleIOS6);
                     break;
              case R.id.ios7:
                     setTheme(R.style.ActionSheetStyleIOS7);
                     break;
              }
              showActionSheet();
       }

       public void showActionSheet()
       {
              ActionSheet.createBuilder(this, getSupportFragmentManager())
              .setCancelButtonTitle("Cancel")
              .setOtherButtonTitles("Add", "Delete", "Edit")
              .setCancelableOnTouchOutside(true).setListener(this).show();
       }

       @Override
       public void onOtherButtonClick(ActionSheet actionSheet, int index)
       {
              Toast.makeText(getApplicationContext(), "click item index = " + index,
                           0).show();
       }

       @Override
       public void onDismiss(ActionSheet actionSheet, boolean isCancle)
       {
              Toast.makeText(getApplicationContext(), "dismissed isCancle = " + isCancle, 0).show();
       }


}


Download Sample Code :  ActionsheetSample

I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

2 comments: