I am having a hard time making a Preference with Dialog, none of the methods suggested in the site works for me. So here is what I have first. In MainActivity I have this
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_stage_1, menu);
return true;
}
This opens the menu, and when you choose Settings, in the next screen there is only one preference, created from this preferences.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference
android:summary="clears all data"
android:title="Reset Data" >
<intent
android:targetClass="com.example.myapp.settings.DialogActivity"
android:targetPackage="com.example.myapp" >
</intent>
</Preference>
I want when I click this option, a dialog to appear with Yes and No button, so I ca define somewhere what the buttons will do programatically. How can I do it?
setDialogMessage()
method inside the constructor with a resource ID to a string value. – Lidialidice