Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. @Override
  2. public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
  3.  
  4. players.clear();
  5. // First Check if cursor is not null
  6. if(cursor != null ) {
  7.  
  8.  
  9. StringBuilder result = new StringBuilder();
  10.  
  11. // Now loop to all items and append it to string builder
  12. while (cursor.moveToNext()) {
  13.  
  14. String id = cursor.getString(cursor.getColumnIndex("ID"));
  15. String name = cursor.getString(cursor.getColumnIndex("ITEM_NAME"));
  16. String qty = cursor.getString(cursor.getColumnIndex("QUANTITY"));
  17. String inst = cursor.getString(cursor.getColumnIndex("INSTRUCTION"));
  18. String pid = cursor.getString(cursor.getColumnIndex("POS_ID"));
  19.  
  20. players.add("Items :" + name + "n" + "Qty :" + qty + "n" +
  21. "Details :" + inst + "n" + " Pos ID :" + pid);
  22.  
  23.  
  24. gv.setAdapter(adapter);
  25. resultView.setText(result);
  26. }
  27.  
  28. } else {
  29. // If cursor is null then display toast amd set empty data.
  30. resultView.setText("Empty data");
  31. Toast.makeText(MainActivity.this, "May be there is no app corresponding to your provider or there is null data.",
  32. Toast.LENGTH_LONG).show();
  33. }
  34.  
  35. }
  36.  
  37. <?xml version="1.0" encoding="utf-8"?>
  38. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  39. xmlns:tools="http://schemas.android.com/tools"
  40. android:layout_width="fill_parent"
  41. android:layout_height="fill_parent"
  42. android:background="#ffffff"
  43. android:fillViewport="true"
  44. tools:context="com.condorpos.kitchen_bumpbar.MainActivity">
  45.  
  46. <LinearLayout
  47. android:layout_width="fill_parent"
  48. android:layout_height="wrap_content"
  49. android:orientation="vertical"
  50. android:padding="5dp">
  51.  
  52. <Button
  53. android:id="@+id/btnRetrieve"
  54. android:layout_width="fill_parent"
  55. android:layout_height="wrap_content"
  56. android:layout_margin="5dp"
  57. android:padding="5dp"
  58. android:text="@string/show_data" />
  59.  
  60. <TextView
  61. android:id="@+id/result"
  62. android:layout_width="fill_parent"
  63. android:layout_height="wrap_content"
  64. android:layout_margin="5dp"
  65. android:clickable="false"
  66. android:padding="5dp"
  67. android:textColor="#000000"
  68. android:textSize="15sp" />
  69.  
  70. <GridView
  71. android:layout_width="match_parent"
  72. android:layout_height="420dp"
  73. android:numColumns="5"
  74. android:verticalSpacing="140dp"
  75. android:id="@+id/gridView1"/>
  76.  
  77. <android.support.v7.widget.RecyclerView
  78. android:id="@+id/expListView"
  79. android:layout_width="match_parent"
  80. android:layout_height="0dp"
  81. android:layout_weight="1"
  82. android:visibility="invisible" />
  83.  
  84. <TextView
  85. android:id="@+id/empty_view"
  86. android:layout_width="match_parent"
  87. android:layout_height="match_parent"
  88. android:gravity="center"
  89. android:visibility="gone"
  90. android:text="@string/empty_list"
  91. android:layout_marginLeft="8dp"
  92. android:layout_marginRight="8dp"/>
  93.  
  94. </LinearLayout>
  95. </LinearLayout>
  96.  
  97. Griview gv;
  98.  
  99. gv=(GridView) findViewById(R.id.gridView1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement