Using Sherlock on Android 2.3.4:
I would like to show an AlertDialog
containing:
1)A title
2)A content
3)2 buttons
I'm using the below class:
public class MyAlertDialog extends SherlockDialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
builder.setMessage("Title")
.setPositiveButton("Fire!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// FIRE ZE MISSILES!
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}
in my Activity i'm calling :
MyAlertDialog m = new MyAlertDialog();
m.show(getSupportFragmentManager(), "hey");
It is showing the AlertDialog but with the old theme(Remember i'm using Android 2.3.4)
Here is my entire main activity class if you want:
public class MainActivity extends SherlockFragmentActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar ab;
ab = getSupportActionBar();
ab.setTitle("Testing Sherlock");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
getSupportMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId())
{
case R.id.action_one:
MyAlertDialog m = new MyAlertDialog();
m.show(getSupportFragmentManager(), "hey");
break;
}
return super.onOptionsItemSelected(item);
}
}
The style i'm setting for my app is:
<resources>
<style name="AppBaseTheme" parent="@style/Theme.Sherlock.Light">
</resources>
P.S: I have the ActionBar
displayed and everything is working fine except the theme of AlertDialog
.
I want it to appear like this one:
and not like this one: