Android Open Source - android-roadkill List Data






From Project

Back to project page android-roadkill.

License

The source code is released under:

GNU General Public License

If you think the Android project android-roadkill listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.ucdavis.cros.roadkill;
//w  w w .  j  a va2  s  .c  o  m
import java.util.ArrayList;

import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ListData extends ListActivity {
  private myDbAdapter myDbHelper;
  private Cursor cursor;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.datalist);
    this.getListView().setDividerHeight(2);
    myDbHelper = new myDbAdapter(this);
    myDbHelper.open();
    fillData();
    registerForContextMenu(getListView());
    myDbHelper.close();
  }

  private void fillData() {
    ArrayList stringList = new ArrayList();
    cursor = myDbHelper.allrecords();

    cursor.moveToFirst();
    if (cursor.isAfterLast() == true) {
      stringList.add("No Records");
    }

    while (cursor.isAfterLast() == false) {
      stringList.add(cursor.getString(0) + ": " + cursor.getString(2));
      cursor.moveToNext();
    }

    this.setListAdapter(new ArrayAdapter<String>(this, R.layout.datarow,
        stringList));

    /*
     * Cursor c = db.rawQuery("SELECT * FROM table WHERE 0", null); try {
     * String[] columnNames = c.columnNames(); } finally { c.close(); }
     */
  }

  protected void onListItemClick(ListView l, View v, int position, long id) {
    myDbHelper.open();
    String selection = l.getItemAtPosition(position).toString();
    cursor = myDbHelper.queryId(selection.substring(0, 1));
    cursor.moveToFirst();
    MySqlHandler msh = new MySqlHandler();
    Toast.makeText(this, cursor.getString(2), Toast.LENGTH_LONG).show();
    myDbHelper.close();
  }
}




Java Source Code List

edu.ucdavis.cros.roadkill.CopyOfCopyOfMySqlHandler.java
edu.ucdavis.cros.roadkill.CopyOfMySqlHandler.java
edu.ucdavis.cros.roadkill.DataBaseHelper.java
edu.ucdavis.cros.roadkill.DataList.java
edu.ucdavis.cros.roadkill.DateTime.java
edu.ucdavis.cros.roadkill.DbAdapter.java
edu.ucdavis.cros.roadkill.GPSHandler.java
edu.ucdavis.cros.roadkill.ListData.java
edu.ucdavis.cros.roadkill.MapChoose.java
edu.ucdavis.cros.roadkill.MapData.java
edu.ucdavis.cros.roadkill.MySqlHandler.java
edu.ucdavis.cros.roadkill.Roadkill.java
edu.ucdavis.cros.roadkill.SpCurAdapter.java
edu.ucdavis.cros.roadkill.TakeGps.java
edu.ucdavis.cros.roadkill.TakePhoto.java
edu.ucdavis.cros.roadkill.Tools.java
edu.ucdavis.cros.roadkill.TransparentPanel.java
edu.ucdavis.cros.roadkill.myDbAdapter.java