-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #829 from SimpleCodeCX/master
实验二,更新activity文件 #88
- Loading branch information
Showing
15 changed files
with
403 additions
and
1 deletion.
There are no files selected for viewing
52 changes: 51 additions & 1 deletion
52
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/Com1314080901208.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
81 changes: 81 additions & 0 deletions
81
...in/java/edu/hzuapps/androidworks/homeworks/com1314080901208/activity_com1314080901208.xml
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,81 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@drawable/login_bg" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context=".Com1314080901208" > | ||
|
||
|
||
<RelativeLayout | ||
android:id="@+id/rl1" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/userName" | ||
android:layout_width="fill_parent" | ||
android:layout_height="50px" | ||
android:layout_centerVertical="true" | ||
android:layout_margin="20dp" | ||
android:background="#7FFFD4" | ||
android:hint="请输入用户名" /> | ||
</RelativeLayout> | ||
|
||
<RelativeLayout | ||
android:id="@+id/rl2" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/rl1" > | ||
|
||
<EditText | ||
android:id="@+id/password" | ||
android:layout_width="fill_parent" | ||
android:layout_height="50px" | ||
android:layout_centerVertical="true" | ||
android:layout_margin="20dp" | ||
android:background="#7FFFD4" | ||
android:hint="请输入密码" | ||
android:textColor="#FFF" /> | ||
</RelativeLayout> | ||
|
||
|
||
|
||
<RelativeLayout | ||
android:id="@+id/rl3" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/rl2" > | ||
|
||
<Button | ||
android:id="@+id/TiJiaoBtn" | ||
android:layout_width="fill_parent" | ||
android:layout_height="60px" | ||
android:layout_centerVertical="true" | ||
android:layout_margin="30dp" | ||
android:text="登录" | ||
android:background="#458B74" | ||
android:textColor="#FFF" /> | ||
</RelativeLayout> | ||
<RelativeLayout | ||
android:id="@+id/rl4" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/rl3" > | ||
|
||
<Button | ||
android:id="@+id/RegisterBtn" | ||
android:layout_width="wrap_content" | ||
android:layout_height="60px" | ||
android:layout_centerVertical="true" | ||
|
||
android:layout_marginTop="200dp" | ||
android:text="注册" | ||
android:background="#458B74" | ||
android:textColor="#FFF" /> | ||
</RelativeLayout> | ||
|
||
</RelativeLayout> |
Binary file added
BIN
+168 KB
.../edu/hzuapps/androidworks/homeworks/com1314080901208/drawable-hdpi/login_bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+444 KB
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions
70
...src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验4/AcountListView.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,70 @@ | ||
package com.example.passwordbox; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.database.Cursor; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.AdapterView; | ||
import android.widget.AdapterView.OnItemClickListener; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.ListView; | ||
import android.widget.Toast; | ||
|
||
public class AcountListView extends Activity{ | ||
private List<AcountData> acountList=new ArrayList<AcountData>(); | ||
private MyDatabaseHelper dbHelper; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// TODO Auto-generated method stub | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.acount_listview); | ||
initAcount(); | ||
AcountAdapter adapter=new AcountAdapter(AcountListView.this,R.layout.acount_item, acountList); | ||
ListView listView=(ListView)findViewById(R.id.list_view_acount); | ||
listView.setAdapter(adapter); | ||
listView.setOnItemClickListener(new OnItemClickListener() { | ||
public void onItemClick(AdapterView<?> parent, View view,int position, long id) | ||
{ | ||
AcountData acountData = acountList.get(position); | ||
Intent intent=new Intent(AcountListView.this,AcountDetails.class);//显示Intent | ||
intent.putExtra("acountId", String.valueOf(acountData.getAcountId())); | ||
startActivity(intent); | ||
} | ||
}); | ||
Button addAcountBtn=(Button)findViewById(R.id.addAcountBtn); | ||
addAcountBtn.setOnClickListener(new OnClickListener() { | ||
|
||
@Override | ||
public void onClick(View arg0) { | ||
// TODO Auto-generated method stub | ||
Intent intent=new Intent(AcountListView.this,AddAcount.class);//显示Intent | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
private void initAcount() | ||
{ | ||
dbHelper=new MyDatabaseHelper(this, "PasswordBox.db", null, 2); | ||
SQLiteDatabase db=dbHelper.getWritableDatabase(); | ||
// 查询Acount表中所有的数据 | ||
Cursor cursor=db.rawQuery("select * from Acount", null); | ||
if(cursor.moveToFirst()) | ||
{ | ||
do{ | ||
int id=cursor.getInt(cursor.getColumnIndex("id")); | ||
String acountLabel=cursor.getString(cursor.getColumnIndex("acountLabel")); | ||
AcountData acountData=new AcountData(id,acountLabel); | ||
acountList.add(acountData); | ||
} | ||
while(cursor.moveToNext()); | ||
} | ||
cursor.close(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验4/AddAcount.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,45 @@ | ||
package com.example.passwordbox; | ||
|
||
import android.app.Activity; | ||
import android.content.ContentValues; | ||
import android.content.Intent; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
public class AddAcount extends Activity{ | ||
private MyDatabaseHelper dbHelper; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// TODO Auto-generated method stub | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.add_acount); | ||
dbHelper=new MyDatabaseHelper(this, "PasswordBox.db", null, 2); | ||
Button addCountBtn=(Button)findViewById(R.id.addCount); | ||
addCountBtn.setOnClickListener(new OnClickListener() { | ||
|
||
@Override | ||
public void onClick(View arg0) { | ||
// TODO Auto-generated method stub | ||
EditText userName = (EditText) findViewById(R.id.userName); | ||
EditText password = (EditText) findViewById(R.id.password); | ||
EditText notes = (EditText) findViewById(R.id.notes); | ||
EditText acountLabel = (EditText) findViewById(R.id.acountLabel); | ||
SQLiteDatabase db = dbHelper.getWritableDatabase(); | ||
ContentValues values = new ContentValues(); | ||
values.put("acountLabel", acountLabel.getText().toString()); | ||
values.put("userName", password.getText().toString()); | ||
values.put("password", userName.getText().toString()); | ||
values.put("notes", notes.getText().toString()); | ||
db.insert("Acount", null, values); | ||
Toast.makeText(AddAcount.this,"Ìí¼ÓÕ˺ųɹ¦",Toast.LENGTH_LONG).show(); | ||
Intent intent=new Intent(AddAcount.this,AcountListView.class);//ÏÔʾIntent | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验4/AndroidManifest.xml
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,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.passwordbox" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="18" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name="com.example.passwordbox.Com1314080901208" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<!-- 这里是activity2 --> | ||
<activity | ||
android:name="com.example.passwordbox.activity2" | ||
android:label="activity2"> | ||
<intent-filter> | ||
<!-- 在<action> 标签中我们指明了当前活动可以响应com.example.passwordbox.ACTION_START 这个action --> | ||
<action android:name="com.example.passwordbox.ACTION_START" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.MY_CATEGORY" /> | ||
</intent-filter> | ||
</activity> | ||
<!-- 这里是 register--> | ||
<activity | ||
android:name="com.example.passwordbox.Register" | ||
android:label="Register"> | ||
</activity> | ||
<!-- 这里是 AddAcount--> | ||
<activity | ||
android:name="com.example.passwordbox.AddAcount" | ||
android:label="AddAcount"> | ||
</activity> | ||
|
||
<!-- 这里是 AcountListView--> | ||
<activity | ||
android:name="com.example.passwordbox.AcountListView" | ||
android:label="AcountListView"> | ||
</activity> | ||
<!-- 这里是 AcountDetails--> | ||
<activity | ||
android:name="com.example.passwordbox.AcountDetails" | ||
android:label="AcountDetails"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
26 changes: 26 additions & 0 deletions
26
...src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验4/acount_listview.xml
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,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
<RelativeLayout | ||
android:id="@+id/rl" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<Button | ||
android:id="@+id/addAcountBtn" | ||
android:layout_width="fill_parent" | ||
android:layout_height="60px" | ||
android:layout_centerVertical="true" | ||
android:layout_margin="30dp" | ||
android:text="添加账号" | ||
android:background="#458B74" | ||
android:textColor="#FFF" /> | ||
</RelativeLayout> | ||
<ListView | ||
android:id="@+id/list_view_acount" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
</ListView> | ||
</LinearLayout> |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901208/实验4/add_acount.xml
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<EditText android:id="@+id/acountLabel" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="标签如:淘宝账号" /> | ||
<EditText android:id="@+id/userName" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="请输入用户名" /> | ||
<EditText android:id="@+id/password" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="请输入密码" /> | ||
<EditText android:id="@+id/notes" | ||
android:layout_width="fill_parent" | ||
android:layout_height="150px" | ||
android:hint="请输入账号描述" /> | ||
<Button android:id="@+id/addCount" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="添加账号"/> | ||
</LinearLayout> |
Binary file added
BIN
+12.8 KB
...u/hzuapps/androidworks/homeworks/com1314080901208/实验6-sqllite的使用/Acount表结构图.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.7 KB
...du/hzuapps/androidworks/homeworks/com1314080901208/实验6-sqllite的使用/Login表结构图.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.