URL and Link repository

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

public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder aDb = new AlertDialog.Builder(getActivity());
aDb.setMessage("Sure about this?");
aDb.setPositiveButton("Yes", null);
aDb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int which) {
return aDb.create();
II. Filename: DataActivity.java
public class DataActivity extends Activity
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
ActionBar actbar = getActionBar();
// Declare Screen output
// Bunch of code omitted for this example...
lv = (ListView)findViewById(R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
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