Widespread Augmented Reality

Widespread Augmented Reality
Click on the image to get the Android Augmented Reality Heads up Display

Wednesday, September 25, 2013

Implementing the Android Dialog Fragment

This is how my code works for a Yes|No fragment dialog box when clicking an item in the ListView activity. Download the full source code here. GitHub repository here.

Sunday, September 8, 2013

Android Fragment Class Coded Directly on Samsung Galaxy Tab 7 inch

Using AIDE and Droid Edit to create extra class files in the AppProjects directory, I threw together a simple Dialog Fragment class like so:
I. Filename: MyDiagFrag.java
public class MyDiagFrag extends DialogFragment {
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();
}
}
II. Filename: DataActivity.java
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....