forked from hzuapps/android-labs-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f175bda
commit dbd022d
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
.../java/edu/hzuapps/androidlabs/homeworks/net1414080903113/Net1414080903113AddActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package edu.androidlabs.homeworks.Net1414080903113; | ||
|
||
import android.content.ContentValues; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.database.sqlite.SQLiteOpenHelper; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
|
||
import com.example.administrator.studentjob.R; | ||
|
||
public class Net1414080903113AddActivity extends AppCompatActivity { | ||
|
||
EditText etName; | ||
EditText etSalary; | ||
EditText etTime; | ||
EditText etLocation; | ||
|
||
Button bt; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903113_add); | ||
etName= (EditText) findViewById(R.id.et_name); | ||
etSalary= (EditText) findViewById(R.id.et_salary); | ||
etTime= (EditText) findViewById(R.id.et_time); | ||
etLocation= (EditText) findViewById(R.id.et_location); | ||
bt= (Button) findViewById(R.id.bt_submit); | ||
bt.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Net1414080903113JobInfo net1414080903113JobInfo =new Net1414080903113JobInfo(); | ||
net1414080903113JobInfo.setName(etName.getText().toString()); | ||
net1414080903113JobInfo.setLocation(etLocation.getText().toString()); | ||
net1414080903113JobInfo.setOccurTime(etTime.getText().toString()); | ||
net1414080903113JobInfo.setSalary(etSalary.getText().toString()); | ||
save(net1414080903113JobInfo); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public void save(Net1414080903113JobInfo bean){ | ||
SQLiteOpenHelper helper=new Net1414080903113MySQLiteOpenHelper(this); | ||
SQLiteDatabase db=helper.getWritableDatabase(); | ||
ContentValues values=new ContentValues(); | ||
values.put("name",bean.getName()); | ||
values.put("salary",bean.getSalary()); | ||
values.put("time",bean.getOccurTime()); | ||
values.put("location",bean.getLocation()); | ||
db.insert("job",null,values); | ||
db.close(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...java/edu/hzuapps/androidlabs/homeworks/net1414080903113/Net1414080903113MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package edu.androidlabs.homeworks.Net1414080903113; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.example.administrator.studentjob.R; | ||
|
||
public class Net1414080903113MainActivity extends AppCompatActivity { | ||
|
||
|
||
Button btJson; | ||
Button btAdd; | ||
Button btQuery; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903113_main); | ||
btAdd= (Button) findViewById(R.id.bt_add); | ||
btJson= (Button) findViewById(R.id.bt_json); | ||
btQuery= (Button) findViewById(R.id.bt_query); | ||
btAdd.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Intent(Net1414080903113MainActivity.this,Net1414080903113AddActivity.class); | ||
} | ||
}); | ||
btQuery.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Intent(Net1414080903113MainActivity.this,Net1414080903113ListInfoActivity.class); | ||
} | ||
}); | ||
btJson.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new Intent(Net1414080903113MainActivity.this,Net1414080903113ShowJsonActivity.class); | ||
} | ||
}); | ||
} | ||
} |