Skip to content

Commit

Permalink
hzuapps#95 hzuapps#20 lab9综合编程
Browse files Browse the repository at this point in the history
  • Loading branch information
soleMemory committed May 11, 2016
1 parent 6d99c58 commit 2ac0266
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package edu.hzuapps.androidworks.homeworks.Net134080903234;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


/**
* Created by ljl on 2016/4/18 0018.
*/
public class Net1314080903234Db extends SQLiteOpenHelper {

public Db(Context context) {
public Net1314080903234Db(Context context) {
super(context, "db", null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table whereYou(" +
db.execSQL("create table whereYou(" +
"_id integer PRIMARY KEY AUTOINCREMENT," +
"longitude text DEFAULT \"\"," +
"latitude text DEFAULT \"\")");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.hzuapps.androidworks.homeworks.Net134080903234;

import android.app.Activity;
import android.app.ListActivity;
import android.content.ContentValues;
import android.content.Context;
Expand All @@ -18,27 +17,37 @@
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import edu.hzuapps.androidworks.R;

public class Net1314080903234GPS extends ListActivity {

private EditText editText;
private LocationManager lm;
private SQLiteDatabase dbRead,dbWrite;
private Db db;
private Net1314080903234Db db;
private SimpleCursorAdapter adapter;
private Button button;
private TextView textView;
private static final String TAG="GpsActivity";
private boolean flag=true;






//获取当前时间
SimpleDateFormat formatter= new SimpleDateFormat ("yyyy.MM.dd HH:mm:ss");
Expand All @@ -49,19 +58,27 @@ public class Net1314080903234GPS extends ListActivity {
private View.OnClickListener btnListener= new View.OnClickListener() {
@Override
public void onClick(View v) {
if(getListView().getVisibility()==View.VISIBLE) {
Toast.makeText(getApplicationContext(),"显示历史记录",Toast.LENGTH_SHORT).show();
if(flag) {
getListView().setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(), "显示历史记录", Toast.LENGTH_SHORT).show();
setListAdapter(adapter);
refresh();
flag=false;
}
else {
getListView().setVisibility(View.INVISIBLE);
Toast.makeText(getApplicationContext(), "关闭历史记录", Toast.LENGTH_SHORT).show();
flag=true;
}


}
};






@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -70,12 +87,15 @@ public void onCreate(Bundle savedInstanceState) {
button.setOnClickListener(btnListener);





//读数据库
db =new Db(this);
db =new Net1314080903234Db(this);
dbRead = db.getReadableDatabase();
dbWrite=db.getWritableDatabase();

adapter = new SimpleCursorAdapter(this,R.layout.where_you,null,
adapter = new SimpleCursorAdapter(this, R.layout.net1314080903234where_you,null,
new String[]{"longitude","latitude"},
new int[]{R.id.tvLong,R.id.tvLat});
// setListAdapter(adapter);
Expand Down Expand Up @@ -161,6 +181,7 @@ public void onStatusChanged(String provider, int status, Bundle extras) {
}
}


/**
* GPS开启时触发
*/
Expand Down

0 comments on commit 2ac0266

Please sign in to comment.