1,534
10
Essay, 2 pages (500 words)

Package stringbuffer oldteach = new stringbuffer(); stringbuffer info

package com. example. yasminanunez. timetable; import android. content. DialogInterface; import android. content. Intent; import android. database. Cursor; import android. os. Bundle; import android. support. v7. app. AlertDialog; import android. support. v7. app. AppCompatActivity; import android. support. v7. widget. Toolbar; import android. view. View; import android. widget. AdapterView; import android. widget. Button; import android. widget. ListView; import android. widget. Toast; public class Friday extends AppCompatActivity { DatabaseHelper helper; //declaring Databasehelper private ListView listView; private Toolbar toolbar; private Button btnAdd; @Override protected void onCreate(Bundle savedInstanceState) { super. onCreate(savedInstanceState); setContentView(R. layout. fri_main); helper = new DatabaseHelper(this); //creating an instance of DatabaseHelper listView = (ListView) findViewById(R. id. listView); btnAdd = (Button) findViewById(R. id. btnAdd); toolbar = (Toolbar) findViewById(R. id. tool_bar); //attaching the toolbar layout to the object //setting toolbar setSupportActionBar(toolbar); getSupportActionBar(). setDisplayShowHomeEnabled(true); populateList(); //calling function to populate my list //button that takes us to Adding activity btnAdd. setOnClickListener(new View. OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Friday. this, Adding. class); intent. putExtra(“ Day”, “ Friday”); //passing weekDay string to next activity startActivity(intent); //starting the activity finish(); //stopping the activity } }); //when a list item is called listView. setOnItemClickListener(new AdapterView. OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int itemPosition, long id) { String day = “ Friday”; Cursor getName = (Cursor) parent. getAdapter(). getItem(itemPosition); //getting the position of item clicked String name = getName. getString(getName. getColumnIndex(“ name”)); //taking the position and putting the item name in String //Cursors to retrieve the data from the database Cursor gettingData = helper. getItemID(name, day); Cursor gettingDetails = helper. getDetails(name, day); //declaring buffers for variables StringBuffer oldST = new StringBuffer(); StringBuffer oldET = new StringBuffer(); StringBuffer oldLoc = new StringBuffer(); StringBuffer oldCT = new StringBuffer(); StringBuffer oldTeach = new StringBuffer(); StringBuffer info = new StringBuffer(); //checking if data has been retrieved or not if(gettingData == null || gettingDetails == null){ toastMessage(“ Nothing was found”); return; } //if data exists if(gettingData != null || gettingDetails != null) { //assigning data to buffer gettingData. moveToFirst(); info. append(“ Location : ” + gettingData. getString(0) + ”
“); info. append(“ Class Type : ” + gettingData. getString(1) + ”
“); info. append(“ Teacher : ” + gettingData. getString(2) + ”

“); //assigning data to corresponding buffer gettingDetails. moveToFirst(); oldST. append(gettingDetails. getString(0)); oldET. append(gettingDetails. getString(1)); oldLoc. append(gettingDetails. getString(2)); oldCT. append(gettingDetails. getString(3)); oldTeach. append(gettingDetails. getString(4)); } //calling function and passing in information to Alert function showMessage(“ Subject Information”, info. toString(), name, oldST. toString(), oldET. toString(), oldLoc. toString(), oldCT. toString(), oldTeach. toString()); } }); } public void showMessage(String title, String alertMessage, final String name, final String oldST, final String oldET, final String oldLoc, final String oldCT, final String oldTeach){ //creating an instance of AlertDialog AlertDialog. Builder alert = new AlertDialog. Builder(this); alert. setCancelable(true); alert. setTitle(title); alert. setMessage(alertMessage); //button that will take you to the Editing activty alert. setPositiveButton(“ EDIT”, new DialogInterface. OnClickListener() { public void onClick(DialogInterface dialog, int id) { //passing strings into the activity for the updating and editing subject Intent intent = new Intent(Friday. this, Editing. class); intent. putExtra(“ Day”, “ Friday”); intent. putExtra(“ Name”, name); intent. putExtra(“ oldST”, oldST); intent. putExtra(“ oldET”, oldET); intent. putExtra(“ oldLoc”, oldLoc); intent. putExtra(“ oldCT”, oldCT); intent. putExtra(“ oldTeach”, oldTeach); startActivity(intent); finish(); } }); //button that will close the pop up alert. setNegativeButton(“ CLOSE”, new DialogInterface. OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog. cancel(); } }); alert. show(); } private void toastMessage(String message){ Toast. makeText(this, message, Toast. LENGTH_SHORT). show(); } //function called to populate the list in each week day private void populateList() { String item = “ Friday”; //Cursor that will call the DatabaseHelper and select the data needed Cursor data = helper. getData(item); //will position to the start of the database data. moveToFirst(); //loop that will continue to add any subjects added while(! data. isAfterLast()){ //creating an instance of the Cursor Adapter //passing in strings and textEdit id’s to adapter MyCursorAdapter cursorAdapter = new MyCursorAdapter(this, R. layout. adapter_view_layout2, data, new String { “ name”, “ startTime”}, new int { R. id. name, R. id. time}); cursorAdapter. notifyDataSetChanged(); //assign listView to Cursor Adapter listView. setAdapter(cursorAdapter); //move cursor to the next value data. moveToNext(); } }}

Thank's for Your Vote!
Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Page 1
Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Page 2
Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Page 3
Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Page 4
Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Page 5

This work, titled "Package stringbuffer oldteach = new stringbuffer(); stringbuffer info" was written and willingly shared by a fellow student. This sample can be utilized as a research and reference resource to aid in the writing of your own work. Any use of the work that does not include an appropriate citation is banned.

If you are the owner of this work and don’t want it to be published on AssignBuster, request its removal.

Request Removal
Cite this Essay

References

AssignBuster. (2022) 'Package stringbuffer oldteach = new stringbuffer(); stringbuffer info'. 29 September.

Reference

AssignBuster. (2022, September 29). Package stringbuffer oldteach = new stringbuffer(); stringbuffer info. Retrieved from https://assignbuster.com/package-stringbuffer-oldteach-new-stringbuffer-stringbuffer-info/

References

AssignBuster. 2022. "Package stringbuffer oldteach = new stringbuffer(); stringbuffer info." September 29, 2022. https://assignbuster.com/package-stringbuffer-oldteach-new-stringbuffer-stringbuffer-info/.

1. AssignBuster. "Package stringbuffer oldteach = new stringbuffer(); stringbuffer info." September 29, 2022. https://assignbuster.com/package-stringbuffer-oldteach-new-stringbuffer-stringbuffer-info/.


Bibliography


AssignBuster. "Package stringbuffer oldteach = new stringbuffer(); stringbuffer info." September 29, 2022. https://assignbuster.com/package-stringbuffer-oldteach-new-stringbuffer-stringbuffer-info/.

Work Cited

"Package stringbuffer oldteach = new stringbuffer(); stringbuffer info." AssignBuster, 29 Sept. 2022, assignbuster.com/package-stringbuffer-oldteach-new-stringbuffer-stringbuffer-info/.

Get in Touch

Please, let us know if you have any ideas on improving Package stringbuffer oldteach = new stringbuffer(); stringbuffer info, or our service. We will be happy to hear what you think: [email protected]