104 lines
3.2 KiB
Java
104 lines
3.2 KiB
Java
package my_view;
|
|
|
|
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.os.Bundle;
|
|
import android.util.DisplayMetrics;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
|
|
import com.sl.house_property.R;
|
|
|
|
|
|
public class ConfirmViewDialog extends Dialog {
|
|
|
|
private Context context;
|
|
private String title1;
|
|
private String title2;
|
|
private String title3;
|
|
private String title4;
|
|
private String confirmButtonText;
|
|
private String cacelButtonText;
|
|
private ClickListenerInterface clickListenerInterface;
|
|
private Bitmap bitmap;
|
|
|
|
public interface ClickListenerInterface {
|
|
|
|
public void doConfirm();
|
|
|
|
public void doCancel();
|
|
}
|
|
|
|
public ConfirmViewDialog(Context context, String title1, String title2, String title3, String title4, Bitmap bitmap) {
|
|
super(context, R.style.MyDialog);
|
|
this.context = context;
|
|
this.title1 = title1;
|
|
this.title2 = title2;
|
|
this.title3 = title3;
|
|
this.title4 = title4;
|
|
this.bitmap=bitmap;
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
// TODO Auto-generated method stub
|
|
super.onCreate(savedInstanceState);
|
|
|
|
init();
|
|
}
|
|
|
|
public void init() {
|
|
LayoutInflater inflater = LayoutInflater.from(context);
|
|
View view = inflater.inflate(R.layout.confirmview_dialog, null);
|
|
setContentView(view);
|
|
|
|
TextView tvTitle1 = (TextView) view.findViewById(R.id.title1);
|
|
TextView tvTitle2 = (TextView) view.findViewById(R.id.title2);
|
|
TextView tvTitle3 = (TextView) view.findViewById(R.id.title3);
|
|
TextView tvTitle4 = (TextView) view.findViewById(R.id.title4);
|
|
|
|
ImageView imageView=(ImageView)view.findViewById(R.id.myImage);
|
|
|
|
tvTitle1.setText(title1);
|
|
tvTitle2.setText(title2);
|
|
tvTitle3.setText(title3);
|
|
tvTitle4.setText(title4);
|
|
if(bitmap!=null)
|
|
imageView.setImageBitmap(bitmap);
|
|
tvTitle4.setOnClickListener(new clickListener());
|
|
tvTitle4.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View view) {
|
|
dismiss();
|
|
}
|
|
});
|
|
Window dialogWindow = getWindow();
|
|
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
|
|
DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
|
|
lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6
|
|
dialogWindow.setAttributes(lp);
|
|
}
|
|
|
|
public void setClicklistener(ClickListenerInterface clickListenerInterface) {
|
|
this.clickListenerInterface = clickListenerInterface;
|
|
}
|
|
|
|
private class clickListener implements View.OnClickListener {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
int id = v.getId();
|
|
if (id == R.id.title1) {
|
|
clickListenerInterface.doConfirm();
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
} |