I. Filename: MyDiagFrag.java
public class MyDiagFrag extends DialogFragment {II. Filename: DataActivity.java
Context myContext;
public MyDiagFrag() {
//myContext = getActivity();
//empty constructor
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder aDb = new AlertDialog.Builder(getActivity());
aDb.setTitle("Delete");
aDb.setMessage("Sure about this?");
aDb.setPositiveButton("Yes", null);
aDb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
d.dismiss();
}
});
return aDb.create();
}
}
public class DataActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlist);
ActionBar actbar = getActionBar();
actbar.show();
actbar.setDisplayHomeAsUpEnabled(true);
// Declare Screen output
// Bunch of code omitted for this example...
lv = (ListView)findViewById(R.id.list);
lv.setAdapter(mAdapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View view, int position1, long id)
{new MyDiagFrag().show(getFragmentManager(), "MyDiag");}});
// More processing omitted for this example....
No comments:
Post a Comment