SHARE
TWEET

Untitled

a guest Jun 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package cabs.h;
  2.  
  3. import android.widget.SimpleCursorAdapter;
  4. import android.widget.Toast;
  5. import android.widget.AdapterView.AdapterContextMenuInfo;
  6.     public class planner extends ListActivity {
  7.     private static final int ACTIVITY_CREATE=0;
  8.     private static final int ACTIVITY_EDIT=1;
  9.     private static final int INSERT_ID = Menu.FIRST;
  10.     private static final int DELETE_ID = Menu.FIRST + 1;
  11.     private NotesDbAdapter mDbHelper;
  12.     private Long mRowId;
  13.     private ServerResponce AllList;
  14.     // private DeviceListAdapter AllList;
  15.     /** Called when the activity is first created. */
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState)
  18.     {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.listonruntime);
  21.         mDbHelper = new NotesDbAdapter(this);
  22.         mDbHelper.open();
  23.         fillData();
  24.         registerForContextMenu(getListView());
  25.  
  26.         String responce = null ;
  27.        // startManagingCursor(responce);
  28.         //AllList = new ServerResponce(responce);
  29.     }
  30.     private void fillData() {
  31.         Cursor notesCursor = mDbHelper.fetchAllNotes();
  32.         startManagingCursor(notesCursor);
  33.  
  34.         // Create an array to specify the fields we want to display in the list (only TITLE)
  35.         String[] from = new String[]{NotesDbAdapter.KEY_BODY,NotesDbAdapter.KEY_TITLE,NotesDbAdapter.KEY_NUMBER};
  36.  
  37.         int[] to = new int[]{R.id.toptext,R.id.middletext,R.id.circle};
  38.  
  39.        SimpleCursorAdapter notes =  
  40.                                     new SimpleCursorAdapter(this, R.layout.row, notesCursor, from, to);
  41.  
  42.     setListAdapter(notes);
  43.  
  44.     }
  45.  
  46.  
  47.  
  48.  
  49.     @Override
  50.     public void onCreateContextMenu(ContextMenu menu, View v,
  51.             ContextMenuInfo menuInfo) {
  52.         super.onCreateContextMenu(menu, v, menuInfo);
  53.         menu.add(0, DELETE_ID, 0, R.string.menu_delete);
  54.     }
  55.  
  56.     @Override
  57.     public boolean onContextItemSelected(MenuItem item) {
  58.         switch(item.getItemId()) {
  59.             case DELETE_ID:
  60.                 AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  61.                 mDbHelper.deleteNote(info.id);
  62.                 fillData();
  63.                 return true;
  64.         }
  65.         return super.onContextItemSelected(item);
  66.     }
  67.  
  68.       @Override
  69.     protected void onSaveInstanceState(Bundle outState)
  70.     {
  71.         super.onSaveInstanceState(outState);
  72.         saveState();
  73.         outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId);
  74.     }
  75.  
  76.     @Override
  77.     protected void onPause() {
  78.         super.onPause();
  79.         saveState();
  80.     }
  81.  
  82.     @Override
  83.     protected void onResume() {
  84.         super.onResume();
  85.  
  86.     }
  87.        // ServerResponce servresp=new ServerResponce();
  88.        String responceId = Activity1.getData();
  89.         String responceno = Activity2.getData();
  90.         String city = cabbookingapplication.Selection;
  91.         String area = cabbookingapplication.Selection2;
  92.         String exactadd  = cabbookingapplication.Selection3;
  93.         String nearby = cabbookingapplication.Selection4;
  94.         private void saveState() {
  95.         String title =("FROM LOC::"+city+","+area+","+exactadd+","+nearby);
  96.         String body = ("TO LOC::"+city+","+area+","+exactadd+","+nearby);
  97.         String number = (""+responceno+",,"+responceId);
  98.             if (mRowId == null) {
  99.             long id = mDbHelper.createNote(title, body, number);
  100.             if (id > 0) {
  101.                 mRowId = id;
  102.             }
  103.         } else {
  104.             mDbHelper.updateNote(mRowId, title, body,number);
  105.             }
  106.         }
  107.  
  108.     @Override
  109.     protected void onListItemClick(ListView l, View v, int position, long thisID)
  110.     {
  111.         super.onListItemClick(l, v, position, thisID);
  112.         String resposponseid = Activity2.getData();
  113.         Object o = this.getListAdapter().getItemId(position);
  114.  
  115.  
  116.        // String device_name = (String) (planner.this). getListAdapter().getItem(position);
  117.  
  118.  
  119.         Toast.makeText(this, "this row responceid is= " + " " + keyword, Toast.LENGTH_LONG).show();
  120.  
  121.  
  122.     }
  123.  
  124.  
  125.     @Override
  126.     protected void onActivityResult(int requestCode, int resultCode, Intent intent)
  127.     {
  128.         super.onActivityResult(requestCode, resultCode, intent);
  129.         fillData();
  130.  
  131.     }
  132.  
  133. }
  134.      
  135. @Override
  136.     **protected void onListItemClick(ListView l, View v, int position, long thisID)
  137.     {
  138.         super.onListItemClick(l, v, position, thisID);
  139.         String resposponseid = Activity2.getData();
  140.         Object o = this.getListAdapter().getItemId(position);
  141.  
  142.  
  143.  
  144.           Toast.makeText(this, "this row responceid is= " + " " + keyword, Toast.LENGTH_LONG).show();
  145.  
  146.  
  147.     }**
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top