Skip to main content

Create Global DialogTheme

Create global class that will extend by the dialog classes

public class ExtendedDialog extends Dialog {

    public ExtendedDialog(Context context) {
        super(context, R.style.CustomDialog);
    }

    public void setCancelBtnClick(ImageView imgCancel) {
        imgCancel.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void setContentView(int resID) {
        super.setContentView(resID);
        this.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    }
}



Lets see the uses above global dialog

public class SimpleDialog extends ExtendedDialog {

    public SimpleDialog (Context context, String message, View.OnClickListener yesClickListener,
                              View.OnClickListener noClickListener) {
        super(context);
        setContentView(R.layout.dialog_skip_refer_process);
        TextView tvNo = (TextView) findViewById(R.id.tv_skip_no);
        TextView tvYes = (TextView) findViewById(R.id.tv_skip_yes);
        TextView tvMessage = (TextView) findViewById(R.id.tv_message);
        ImageView ivClose = (ImageView) findViewById(R.id.iv_close);
        tvMessage.setText(message);
        tvYes.setOnClickListener(yesClickListener);
        tvNo.setOnClickListener(noClickListener);
        ivClose.setOnClickListener(noClickListener);

    }

}


and at last above will be use in the activity, see below code

private void settingAlertDialog() {
    settingAlertDialog = new SimpleDialog (EditProfileActivity.this, getString(R.string.msg_in_complete_profile), yesClickListener, noClickListener);
    settingAlertDialog.show();
}


View.OnClickListener yesClickListener = new View.OnClickListener() {
    @Override    public void onClick(View view) {
        settingAlertDialog.dismiss();
        finish();
    }
};


View.OnClickListener noClickListener = new View.OnClickListener() {
    @Override    public void onClick(View view) {
        settingAlertDialog.dismiss();
    }
};




///Dialog theme

<!--DIALOG THEME-->
<style name="CustomDialog" parent="Theme.AppCompat.Dialog">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:background">@android:color/transparent</item>
</style>

Comments

Popular posts from this blog

Getview Method Wierd in Listview

Its common issue in android and most of newbee faced. To understand why its happening, you have to read about behavior of Getview method of listivew, its your home work, let continue with tutorial. Below tutorial will explain that how to maintain the position of button  which is in row file using settag and gettag. main.xml ( its contain listview which will hold row data) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:descendantFocusability="blocksDescendants">  <ListView         android:id="@+id/listView"         android:layout_width="fill_parent"         android:layout_height="fill_parent"/> </LinearLayout> ...

Amazon S3 Configuration

Gradles //amazon s3 compile 'com.amazonaws:aws-android-sdk-core:2.2.+' compile 'com.amazonaws:aws-android-sdk-s3:2.2.+' Declare in manefiest file <!--AMAZON S3--> < service android :name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android :enabled= "true" /> AmazonUtils.java import android.content.Context; import android.net.Uri; import com.amazonaws.auth.CognitoCachingCredentialsProvider; import com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver; import com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility; import com.amazonaws.regions.Regions; import com.amazonaws.services.s3.AmazonS3Client; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Map; import java.util.UUID; /* * Handles basic helper functions used throughout the app. */ public class AmazonUtil { // We only n...
Update Progress in notification: public class NetworkService extends IntentService {     public static final String FILE_PATH = "file_path";     public static final String _FILE_PATH = "_path";     public static final String PERCENT_EXTRA = "percent";     public static final String FILE_NAME_EXTRA = "FileName";     public static final String STATE_EXTRA = "state";     public static final String IS_ALBUM_UPLAODING = "IsAlbumUplaoding";     public static final String XML = "xml";     public static final String TOKEN = "token";     public static final String MESSAGE = "mesasge";     public static final String POST_DATE = "postdate";     public static final String USERID = "userid";     public static final String GROUPID = "groupid";     public static final String PATH = "path"; ...