0
我試圖在下面的示例對話框中顯示。它在仿真器上運行正常,但是當我在設備上檢查它時,它沒有顯示任何交易。我也嘗試設置持續時間較長的值。動畫在模擬器上顯示,但在真實設備上
public class AnimActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
Builder builder = new AlertDialog.Builder(this);
builder.setMessage("This will end the activity");
builder.setCancelable(true);
builder.setPositiveButton("I agree", new OkOnClickListener());
builder.setNegativeButton("No, no", new CancelOnClickListener());
final AlertDialog dialog = builder.create();
dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_SmileWindow;
Button btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.show();
}
});
}
private final class CancelOnClickListener implements
DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Activity will continue",
Toast.LENGTH_LONG).show();
}
}
private final class OkOnClickListener implements
DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int which) {
finish();
}
}
}
thanks..its now working .. –