Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. public class MyListActivity extends ListActivity {
  2. /** Called when the activity is first created. */
  3.  
  4.  
  5. private Cursor mCursor = null;
  6.  
  7.  
  8. @SuppressWarnings("deprecation")
  9. @Override
  10. public void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.weeklysettings);
  13. getListView().addHeaderView(buildHeader(), null , false);
  14. Cursor mCursor = getCursorDetails();
  15. startManagingCursor(mCursor);
  16.  
  17. ListAdapter adapter = new SimpleCursorAdapter(this, // Context.
  18. R.layout.listview, // Specify the row template
  19. // to use (here, three
  20. // columns bound to the
  21. // two retrieved cursor
  22. // rows).
  23. mCursor, // Pass in the cursor to bind to.
  24. // Array of cursor columns to bind to.
  25. new String[] { MyClass.EVENT,
  26. MyClass.CHANNEL_NAME,
  27. MyClass.PROGRAM_TITLE,
  28. MyClass.EVENTTIME },
  29.  
  30. new int[] { R.id.event, R.id.channelname, R.id.programtitle, R.id.timestamp});
  31. // Bind to our new adapter.
  32. setListAdapter(adapter);
  33. //setListAdapter(new ArrayAdapter<String>(this, R.layout.listview, ynetList));
  34.  
  35. }
  36.  
  37. @Override
  38. protected void onPause() {
  39. // TODO Auto-generated method stub
  40. super.onPause();
  41. stopManagingCursor(mCursor);
  42. }
  43.  
  44.  
  45. @Override
  46. protected void onResume() {
  47. // TODO Auto-generated method stub
  48. super.onResume();
  49. startManagingCursor(mCursor);
  50. }
  51. private ViewGroup buildHeader() {
  52. LayoutInflater infalter = getLayoutInflater();
  53. ViewGroup header = (ViewGroup) infalter.inflate(R.layout.listitem_header, getListView(), false);
  54. header.setEnabled(false);
  55. return(header);
  56. }
  57. @Override
  58. public void onBackPressed() {
  59. // TODO Auto-generated method stub
  60. Intent intent = new Intent(this, SettingsActivity.class);
  61. intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  62. startActivity(intent);
  63. finish();
  64. super.onBackPressed();
  65. }
  66.  
  67. private Cursor getCursorDetails() {
  68.  
  69.  
  70. String sortOrder = DataExchangeFacility.TIMESTAMP
  71. + " COLLATE LOCALIZED DESC";
  72.  
  73. mCursor = getApplicationContext().getContentResolver().query(
  74. DataExchangeFacility.CONTENT_URI_GRACE, null, null, null, sortOrder);
  75.  
  76. return mCursor;
  77.  
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement