@ -0,0 +1,15 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="17" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||||
|
<file url="PROJECT" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,5 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -0,0 +1,12 @@
|
|||||||
|
<project version="4">
|
||||||
|
<component name="CodeInsightWorkspaceSettings">
|
||||||
|
<option name="optimizeImportsOnTheFly" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("com.example.final_project_app", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- 添加网络权限 -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" /> <!-- 读取权限 -->
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.Final_Project_app"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".QuestionActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".PlayActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".sql.UpdateNoteActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".sql.AddNoteActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".Helpctivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".AboutUsActivity"
|
||||||
|
android:exported="true" />
|
||||||
|
<activity
|
||||||
|
android:name=".login"
|
||||||
|
android:exported="true"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".register"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".Hello_GudieActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity android:name=".Goods.GoodsActivity"
|
||||||
|
android:exported="true"/>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class AboutUsActivity extends AppCompatActivity {
|
||||||
|
private Button btn_back;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_about_us);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
/* btn_back = findViewById(R.id.btn_back);
|
||||||
|
btn_back.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
|
FragmentTransaction ft = fm.beginTransaction();
|
||||||
|
ft.replace(R.id.fg_main,new FourFragment());
|
||||||
|
ft.addToBackStack(null);
|
||||||
|
|
||||||
|
ft.commit();
|
||||||
|
Intent intent = new Intent(AboutUsActivity.this, FourFragment.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link ChexBoxFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class ChexBoxFragment extends Fragment {
|
||||||
|
//成员变量
|
||||||
|
private TextView question_stem;//题干文本框控件,就是选中的控件显示
|
||||||
|
private CheckBox[] cb =new CheckBox[5];
|
||||||
|
private Question question;//题目对象就是标题,单选多选,正确下标
|
||||||
|
private int result;//正确为1 错误为0 未答题为-1
|
||||||
|
private View view;
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
Log.e("复选onCreateView","复选onCreateView执行了");
|
||||||
|
view=inflater.inflate(R.layout.fragment_chex_box, container, false);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
Log.e("复选onViewCreated","复选onViewCreated执行了");
|
||||||
|
//初始化控件
|
||||||
|
initView(view);
|
||||||
|
//更新题目
|
||||||
|
nextQuestion(question);
|
||||||
|
}
|
||||||
|
//获取题目
|
||||||
|
public void setQuestion(Question question){
|
||||||
|
this.question=question;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearChoice(){
|
||||||
|
//清除选择
|
||||||
|
for (int i = 0; i < cb.length; i++) {
|
||||||
|
cb[i].setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//初始化控件
|
||||||
|
public void initView(final View view){
|
||||||
|
Log.e("复选initView","复选initView执行了");
|
||||||
|
//获取题干
|
||||||
|
question_stem=view.findViewById(R.id.question_item2);
|
||||||
|
//单选控件
|
||||||
|
cb[0]=view.findViewById(R.id.boxs1);
|
||||||
|
cb[1]=view.findViewById(R.id.boxs2);
|
||||||
|
cb[2]=view.findViewById(R.id.boxs3);
|
||||||
|
cb[3]=view.findViewById(R.id.boxs4);
|
||||||
|
cb[4]=view.findViewById(R.id.boxs5);
|
||||||
|
}
|
||||||
|
//更新题目
|
||||||
|
public void nextQuestion(Question question){
|
||||||
|
Log.e("复选nextQuestion","nextQuestion执行了");
|
||||||
|
//设置题干
|
||||||
|
Log.e("a",question.getQuestionStem());
|
||||||
|
question_stem.setText(question.getQuestionStem());
|
||||||
|
//设置选项
|
||||||
|
for (int i=0;i<cb.length;i++){
|
||||||
|
//所有选项初始都未选中
|
||||||
|
cb[i].setChecked(false);
|
||||||
|
//设置选项内容
|
||||||
|
cb[i].setText(question.getOptions()[i]);
|
||||||
|
//设置背景颜色
|
||||||
|
cb[i].setBackgroundResource(R.drawable.select_button_text);
|
||||||
|
//设置字体颜色
|
||||||
|
cb[i].setTextColor(getResources().getColor(R.color.black));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断选择结果
|
||||||
|
public int getResult(Question question){
|
||||||
|
//得到正确的选项的下标数组
|
||||||
|
String[] correctOptions = question.getCorrectOptions().split(",");
|
||||||
|
boolean answer = true; //记录正确答案是否选择
|
||||||
|
int checkednum = 0; //选择的选项个数
|
||||||
|
for(int i = 0; i < cb.length; i++){
|
||||||
|
if(cb[i].isChecked()){
|
||||||
|
checkednum++; //选项个数增加
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(checkednum == 0){
|
||||||
|
Toast.makeText(getContext(),"请选择答案!",Toast.LENGTH_SHORT).show();
|
||||||
|
result = -1;
|
||||||
|
}else{
|
||||||
|
for(int i=0;i< cb.length;i++){
|
||||||
|
cb[i].setBackgroundResource(R.drawable.shape_radiobutton2);
|
||||||
|
}
|
||||||
|
if(checkednum==correctOptions.length){
|
||||||
|
for (String correctOption : correctOptions) {
|
||||||
|
//判断对应的选项是否被选择
|
||||||
|
boolean now = cb[Integer.parseInt(correctOption)].isChecked();
|
||||||
|
answer = answer && now;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
answer=false;
|
||||||
|
}
|
||||||
|
if(answer){
|
||||||
|
for (String correctOption : correctOptions) {
|
||||||
|
//判断对应的选项是否被选择
|
||||||
|
CheckBox c = cb[Integer.parseInt(correctOption)];
|
||||||
|
c.setBackgroundResource(R.drawable.shape_success_answer);
|
||||||
|
c.setTextColor(getResources().getColor(R.color.black));
|
||||||
|
}
|
||||||
|
result = 1;
|
||||||
|
}else{
|
||||||
|
for (CheckBox checkBox : cb) {
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
checkBox.setBackgroundResource(R.drawable.shape_error_answer);
|
||||||
|
checkBox.setTextColor(getResources().getColor(R.color.black));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showCorrectAnswer(correctOptions);
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//显示正确答案的dialog
|
||||||
|
private void showCorrectAnswer(String[] correctOptions) {
|
||||||
|
//得到正确答案
|
||||||
|
String answer = "";
|
||||||
|
for (String correctOption : correctOptions) {
|
||||||
|
answer += cb[Integer.parseInt(correctOption)].getText().toString() + "\n";
|
||||||
|
}
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
builder.setTitle("正确答案")
|
||||||
|
.setMessage(answer)
|
||||||
|
.setNegativeButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.example.final_project_app.Fragment;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.final_project_app.AboutUsActivity;
|
||||||
|
import com.example.final_project_app.Helpctivity;
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
import com.example.final_project_app.login;
|
||||||
|
|
||||||
|
public class FourFragment extends FirstFragment {
|
||||||
|
private RelativeLayout quite,aboutus,help;
|
||||||
|
private TextView username,userpwd;
|
||||||
|
SharedPreferences sp1;
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fg_four,container,false);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
//获取用户名和密码控件
|
||||||
|
username = getActivity().findViewById(R.id.username);
|
||||||
|
userpwd = getActivity().findViewById(R.id.userpwd);
|
||||||
|
|
||||||
|
//获取退出控件
|
||||||
|
quite = getActivity().findViewById(R.id.re_quite);
|
||||||
|
//退出点击事件
|
||||||
|
quite.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle("提示");
|
||||||
|
builder.setMessage("是否确定退出");
|
||||||
|
builder.setIcon(R.drawable.back_home0);
|
||||||
|
//确定
|
||||||
|
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
Intent intent = new Intent(getActivity(), login.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//取消
|
||||||
|
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
dialogInterface.dismiss(); //关闭提示框
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//生成提示框并显示
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//关于我们点击事件
|
||||||
|
aboutus = getActivity().findViewById(R.id.re_aboutus);
|
||||||
|
aboutus.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(getActivity(), AboutUsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//帮助与反馈
|
||||||
|
help = getActivity().findViewById(R.id.re_help);
|
||||||
|
help.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(getActivity(), Helpctivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package com.example.final_project_app.Fragment;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
import com.example.final_project_app.adpter.NoteRecyAdapter;
|
||||||
|
import com.example.final_project_app.QuestionActivity;
|
||||||
|
import com.example.final_project_app.db.NoteBook;
|
||||||
|
import com.example.final_project_app.db.NoteData;
|
||||||
|
import com.example.final_project_app.sql.AddNoteActivity;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class ThreeFragment extends FirstFragment {
|
||||||
|
private Button btn_add,btn_awser;
|
||||||
|
|
||||||
|
private NoteBook nb;
|
||||||
|
private RecyclerView recy;
|
||||||
|
private List<NoteData> datas;
|
||||||
|
|
||||||
|
private NoteRecyAdapter mAdapter;
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fg_three, container, false);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
//初始化数据
|
||||||
|
initdata();
|
||||||
|
//获取控件
|
||||||
|
recy = getActivity().findViewById(R.id.recy);
|
||||||
|
mAdapter = new com.example.final_project_app.adpter.NoteRecyAdapter(datas,getContext());
|
||||||
|
LinearLayoutManager lm = new LinearLayoutManager(getContext());
|
||||||
|
recy.setAdapter(mAdapter);
|
||||||
|
recy.setLayoutManager(lm);
|
||||||
|
//添加按钮
|
||||||
|
btn_add = getActivity().findViewById(R.id.btn_add);
|
||||||
|
btn_add.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(getActivity(), AddNoteActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btn_awser = getActivity().findViewById(R.id.btn_awser);
|
||||||
|
btn_awser.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(getActivity(), QuestionActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
refreshData();
|
||||||
|
mAdapter.refresh(datas);
|
||||||
|
}
|
||||||
|
private void refreshData() {
|
||||||
|
datas = getDataFromSQL();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initdata() {
|
||||||
|
datas = new ArrayList<NoteData>();
|
||||||
|
nb = new NoteBook(getContext());
|
||||||
|
datas = getDataFromSQL();
|
||||||
|
}
|
||||||
|
private List<NoteData> getDataFromSQL() {
|
||||||
|
return nb.query();
|
||||||
|
}
|
||||||
|
private String getSystemCurrentTime() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
|
||||||
|
Date datetime = new Date();
|
||||||
|
return sdf.format(datetime);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.example.final_project_app.Goods;
|
||||||
|
|
||||||
|
public class Goods {
|
||||||
|
private int goodsId;
|
||||||
|
private String goodsName;
|
||||||
|
private String goodsNotice;
|
||||||
|
// private int goodsPrice;
|
||||||
|
private int goodsImg;
|
||||||
|
|
||||||
|
public Goods() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Goods(String goodsName, String goodsNotice, int goodPrice, int goodsImg) {
|
||||||
|
this.goodsName = goodsName;
|
||||||
|
this.goodsNotice = goodsNotice;
|
||||||
|
// this.goodsPrice = goodPrice;
|
||||||
|
this.goodsImg = goodsImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGoodsId() {
|
||||||
|
return goodsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsId(int goodsId) {
|
||||||
|
this.goodsId = goodsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGoodsName() {
|
||||||
|
return goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsName(String goodsName) {
|
||||||
|
this.goodsName = goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGoodsNotice() {
|
||||||
|
return goodsNotice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsNotice(String goodsNotice) {
|
||||||
|
this.goodsNotice = goodsNotice;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public int getGoodPrice() {
|
||||||
|
// return goodsPrice;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void setGoodPrice(int goodPrice) {
|
||||||
|
// this.goodsPrice = goodPrice;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public int getGoodsImg() {
|
||||||
|
return goodsImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsImg(int goodsImg) {
|
||||||
|
this.goodsImg = goodsImg;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.example.final_project_app.Goods;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GoodsActivity extends AppCompatActivity {
|
||||||
|
private ImageView imageView;
|
||||||
|
private TextView goodsPrice,goodsName,goodsNotice;
|
||||||
|
|
||||||
|
private List<Goods> goodsList = new ArrayList<>();
|
||||||
|
private Goods goods;
|
||||||
|
private Button gom;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_goods);
|
||||||
|
|
||||||
|
imageView = findViewById(R.id.img);
|
||||||
|
goodsName = findViewById(R.id.name);
|
||||||
|
// goodsPrice = findViewById(R.id.price);
|
||||||
|
goodsNotice = findViewById(R.id.notice);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
int goodsId = intent.getIntExtra("goodsId",0);
|
||||||
|
|
||||||
|
GoodsData goodsData = new GoodsData(GoodsActivity.this);
|
||||||
|
goodsList = goodsData.getGoodsList();
|
||||||
|
goods = goodsList.get(goodsId);
|
||||||
|
|
||||||
|
imageView.setImageResource(goods.getGoodsImg());
|
||||||
|
goodsName.setText(goods.getGoodsName());
|
||||||
|
// goodsPrice.setText("¥"+String.valueOf(goods.getGoodPrice())+"元");
|
||||||
|
goodsNotice.setText(goods.getGoodsNotice());
|
||||||
|
|
||||||
|
// gom = (Button) findViewById(R.id.gm);
|
||||||
|
// gom.setOnClickListener(new View.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(View view) {
|
||||||
|
// Intent intent = new Intent(GoodsActivity.this, plActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class Hello_GudieActivity extends AppCompatActivity {
|
||||||
|
public TextView djs;
|
||||||
|
private android.os.CountDownTimer countDownTimer;
|
||||||
|
private long timeLeftInMillis =6000;
|
||||||
|
private boolean CountDownTimer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_hello_gudie);
|
||||||
|
djs = findViewById(R.id.djs);
|
||||||
|
//启动倒计时
|
||||||
|
startCountdown();
|
||||||
|
}
|
||||||
|
private void startCountdown() {
|
||||||
|
countDownTimer =new CountDownTimer(timeLeftInMillis,1000) {
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) {
|
||||||
|
timeLeftInMillis = millisUntilFinished;
|
||||||
|
int secondsRemaining = (int) (millisUntilFinished / 1000);
|
||||||
|
djs.setText(secondsRemaining +" s");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
//跳转界面
|
||||||
|
startActivity(new Intent(Hello_GudieActivity.this,login.class));
|
||||||
|
// 倒计时结束后跳转到哪个界面
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (countDownTimer != null){
|
||||||
|
countDownTimer.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class Helpctivity extends AppCompatActivity {
|
||||||
|
private Button btn_sure;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_helpctivity);
|
||||||
|
btn_sure = findViewById(R.id.btn_sure);
|
||||||
|
btn_sure.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Toast.makeText(Helpctivity.this, "反馈成功", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.example.final_project_app.Fragment.FirstFragment;
|
||||||
|
import com.example.final_project_app.Fragment.FourFragment;
|
||||||
|
import com.example.final_project_app.Fragment.ThreeFragment;
|
||||||
|
import com.example.final_project_app.Fragment.TwoFragment;
|
||||||
|
import com.example.final_project_app.adpter.MyFragmentPaperAdapter;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener{
|
||||||
|
|
||||||
|
private FrameLayout fg_main;
|
||||||
|
private FragmentManager fm;
|
||||||
|
private ViewPager vp;
|
||||||
|
public static final int PAGE_ONE = 0;
|
||||||
|
public static final int PAGE_TWO = 1;
|
||||||
|
public static final int PAGE_THREE = 2;
|
||||||
|
public static final int PAGE_FOUR = 3;
|
||||||
|
public static final int PAGE_Five = 4;
|
||||||
|
private MyFragmentPaperAdapter mPaperAdapter;
|
||||||
|
private TextView tv1;
|
||||||
|
private TextView tv2;
|
||||||
|
private TextView tv3;
|
||||||
|
private TextView tv4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
fg_main = (FrameLayout) findViewById(R.id.fg_main);
|
||||||
|
vp = (ViewPager) findViewById(R.id.vp);
|
||||||
|
tv1 = (TextView) findViewById(R.id.tv_one);
|
||||||
|
tv2 = (TextView) findViewById(R.id.tv_two);
|
||||||
|
tv3 = (TextView) findViewById(R.id.tv_three);
|
||||||
|
tv4 = (TextView) findViewById(R.id.tv_four);
|
||||||
|
mPaperAdapter = new MyFragmentPaperAdapter(getSupportFragmentManager());
|
||||||
|
vp.setAdapter(mPaperAdapter);
|
||||||
|
vp.setCurrentItem(0);
|
||||||
|
vp.addOnPageChangeListener((ViewPager.OnPageChangeListener) this);
|
||||||
|
|
||||||
|
}
|
||||||
|
//MYClick点击事件
|
||||||
|
public void MyClick(View view){
|
||||||
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
|
FragmentTransaction ft = fm.beginTransaction();
|
||||||
|
|
||||||
|
//创建页面类对象
|
||||||
|
FirstFragment page1 = new FirstFragment();
|
||||||
|
TwoFragment page2 = new TwoFragment();
|
||||||
|
ThreeFragment page3 = new ThreeFragment();
|
||||||
|
FourFragment page4 = new FourFragment();
|
||||||
|
|
||||||
|
|
||||||
|
//点击页面替换
|
||||||
|
if (view.getId()== R.id.tv_one){
|
||||||
|
// ft.replace(R.id.fg_main,page1);
|
||||||
|
vp.setCurrentItem(PAGE_ONE);
|
||||||
|
|
||||||
|
}else if (view.getId()==R.id.tv_two){
|
||||||
|
//ft.replace(R.id.fg_main,page2);
|
||||||
|
vp.setCurrentItem(PAGE_TWO);
|
||||||
|
|
||||||
|
}else if (view.getId()==R.id.tv_three) {
|
||||||
|
// ft.replace(R.id.fg_main, page3);
|
||||||
|
vp.setCurrentItem(PAGE_THREE);
|
||||||
|
|
||||||
|
}else if (view.getId()==R.id.tv_four) {
|
||||||
|
//ft.replace(R.id.fg_main, page4);
|
||||||
|
vp.setCurrentItem(PAGE_FOUR);
|
||||||
|
}
|
||||||
|
ft.commit();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//滑动切换判断事件
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
if (state==2){
|
||||||
|
switch (vp.getCurrentItem()){
|
||||||
|
case PAGE_ONE:
|
||||||
|
tv1.setSelected(true);
|
||||||
|
//tv1.setBackgroundColor(R.color.black);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAGE_TWO:
|
||||||
|
tv2.setSelected(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAGE_THREE:
|
||||||
|
tv3.setSelected(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAGE_FOUR:
|
||||||
|
tv4.setSelected(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import static com.example.final_project_app.db.PermissionUtiils.verifyStoragePermissions;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.MediaController;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class PlayActivity extends AppCompatActivity {
|
||||||
|
private TextView tvvedioname;
|
||||||
|
private VideoView videoView;
|
||||||
|
//媒体控制器
|
||||||
|
private MediaController mediaController;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_play);
|
||||||
|
|
||||||
|
tvvedioname= findViewById(R.id.tvmovename);
|
||||||
|
videoView=findViewById(R.id.vvmovie);
|
||||||
|
mediaController=new MediaController(this);
|
||||||
|
initData();
|
||||||
|
verifyStoragePermissions(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
//获取从列表传过来的视频名称和地址
|
||||||
|
String videoname=getIntent().getStringExtra("my");
|
||||||
|
String videouri=getIntent().getStringExtra("movieurl");
|
||||||
|
//String videourl= Environment.getExternalStorageDirectory().getAbsolutePath()+"/jay.mp4";
|
||||||
|
//Log.i("PlayActivity","videourl="+videourl);
|
||||||
|
//将视频名称显示在文本框中,将视频地址关联到播放器中
|
||||||
|
tvvedioname.setText(videoname);
|
||||||
|
videoView.setVideoPath(videouri);
|
||||||
|
//videoView.setVideoPath(videourl);
|
||||||
|
//将视频播放器和媒体控制柄关联起来
|
||||||
|
videoView.setMediaController(mediaController);
|
||||||
|
//媒体控制柄和视频播放器关联起来
|
||||||
|
mediaController.setMediaPlayer(videoView);
|
||||||
|
//启动视频播放器播放视频
|
||||||
|
videoView.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
public class Question {
|
||||||
|
private String questionStem;//题干
|
||||||
|
private String[] options;//选项
|
||||||
|
private String correctOptions;//正确选项的下标从0开始
|
||||||
|
private int questionTypes;//1 为单选题, 2为多选题
|
||||||
|
|
||||||
|
public Question(String questionStem, String[] options, String correctOptions, int questionTypes) {
|
||||||
|
this.questionStem = questionStem;
|
||||||
|
this.options = options;
|
||||||
|
this.correctOptions = correctOptions;
|
||||||
|
this.questionTypes = questionTypes;
|
||||||
|
}
|
||||||
|
public Question() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuestionStem() {
|
||||||
|
return questionStem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuestionStem(String questionStem) {
|
||||||
|
this.questionStem = questionStem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getOptions() {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptions(String[] options) {
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCorrectOptions() {
|
||||||
|
return correctOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorrectOptions(String correctOptions) {
|
||||||
|
this.correctOptions = correctOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getQuestionTypes() {
|
||||||
|
return questionTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuestionTypes(int questionTypes) {
|
||||||
|
this.questionTypes = questionTypes;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
package com.example.final_project_app;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
|
||||||
|
public class RadioButtonFragment extends Fragment {
|
||||||
|
//成员变量
|
||||||
|
private TextView question_stem;//题干文本框控件,就是选中的控件显示
|
||||||
|
private RadioGroup radioGroup;
|
||||||
|
private RadioButton [] rb =new RadioButton[4];
|
||||||
|
private Question question;//题目对象就是标题,单选多选,正确下标
|
||||||
|
private int result;//正确为1 错误为0 未答题为-1
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
Log.e("单选onCreateView","单选onCreateView执行了");
|
||||||
|
View view=inflater.inflate(R.layout.fragment_radio_button, container, false);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
Log.e("单选onViewCreated","单选onViewCreated执行了");
|
||||||
|
//初始化控件
|
||||||
|
initView(view);
|
||||||
|
//更新题目
|
||||||
|
nextQuestion(question);
|
||||||
|
}
|
||||||
|
//获取题目
|
||||||
|
public void setQuestion(Question question){
|
||||||
|
this.question=question;
|
||||||
|
}
|
||||||
|
//初始化控件
|
||||||
|
public void initView(final View view){
|
||||||
|
Log.e("单选initView","单选initView执行了");
|
||||||
|
//获取题干
|
||||||
|
question_stem=view.findViewById(R.id.question_item);
|
||||||
|
radioGroup=view.findViewById(R.id.radiogroup);
|
||||||
|
//单选控件
|
||||||
|
rb[0]=view.findViewById(R.id.radio1);
|
||||||
|
rb[1]=view.findViewById(R.id.radio2);
|
||||||
|
rb[2]=view.findViewById(R.id.radio3);
|
||||||
|
rb[3]=view.findViewById(R.id.radio4);
|
||||||
|
}
|
||||||
|
//清空原来选项
|
||||||
|
public void clear(){
|
||||||
|
radioGroup.clearCheck();
|
||||||
|
}
|
||||||
|
//更新题目
|
||||||
|
public void nextQuestion(Question question){
|
||||||
|
Log.e("单选nextQuestion","单选nextQuestion执行了");
|
||||||
|
clear();
|
||||||
|
//设置题干
|
||||||
|
question_stem.setText(question.getQuestionStem());
|
||||||
|
//设置选项
|
||||||
|
for (int i=0;i<rb.length;i++){
|
||||||
|
//所有选项初始都未选中
|
||||||
|
rb[i].setChecked(false);
|
||||||
|
//设置选项内容
|
||||||
|
rb[i].setText(question.getOptions()[i]);
|
||||||
|
//设置背景颜色
|
||||||
|
rb[i].setBackgroundResource(R.drawable.select_button_text);
|
||||||
|
//设置字体颜色
|
||||||
|
rb[i].setTextColor(getResources().getColor(R.color.black));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断选择结果
|
||||||
|
public int getResult(Question question){
|
||||||
|
//正确的id下标
|
||||||
|
int correctIndex=Integer.parseInt(question.getCorrectOptions());
|
||||||
|
int correctId=rb[correctIndex].getId();
|
||||||
|
//当前选中的id
|
||||||
|
int radioId=radioGroup.getCheckedRadioButtonId();
|
||||||
|
if(radioId==-1){
|
||||||
|
Toast.makeText(getContext(), "请选择你的选项", Toast.LENGTH_SHORT).show();
|
||||||
|
result=-1;
|
||||||
|
}else {
|
||||||
|
for(int i=0;i< rb.length;i++){
|
||||||
|
rb[i].setBackgroundResource(R.drawable.shape_radiobutton2);
|
||||||
|
}
|
||||||
|
if (radioId==correctId){
|
||||||
|
Toast.makeText(getContext(), "回答正确", Toast.LENGTH_SHORT).show();
|
||||||
|
result=1;
|
||||||
|
}else {
|
||||||
|
//答案错误背景和字体变对应的颜色
|
||||||
|
RadioButton radioButton=getView().findViewById(radioId);
|
||||||
|
radioButton.setBackgroundResource(R.drawable.shape_error_answer);
|
||||||
|
radioButton.setTextColor(getResources().getColor(R.color.black));
|
||||||
|
result=0;
|
||||||
|
}
|
||||||
|
//无论正确还是错误,正确的答案都显示出来
|
||||||
|
rb[correctIndex].setBackgroundResource(R.drawable.shape_success_answer);
|
||||||
|
rb[correctIndex].setTextColor(getResources().getColor(R.color.black));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.example.final_project_app.adpter;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
|
||||||
|
import com.example.final_project_app.Fragment.FirstFragment;
|
||||||
|
import com.example.final_project_app.Fragment.FourFragment;
|
||||||
|
import com.example.final_project_app.Fragment.ThreeFragment;
|
||||||
|
import com.example.final_project_app.Fragment.TwoFragment;
|
||||||
|
import com.example.final_project_app.MainActivity;
|
||||||
|
|
||||||
|
|
||||||
|
public class MyFragmentPaperAdapter extends FragmentPagerAdapter {
|
||||||
|
private final FirstFragment b1;
|
||||||
|
private final TwoFragment b2;
|
||||||
|
private final ThreeFragment b3;
|
||||||
|
private final FourFragment b4;
|
||||||
|
private int PAGE = 4;
|
||||||
|
|
||||||
|
public MyFragmentPaperAdapter(@NonNull FragmentManager fm) {
|
||||||
|
super(fm);
|
||||||
|
|
||||||
|
b1 = new FirstFragment();
|
||||||
|
b2 = new TwoFragment();
|
||||||
|
b3 = new ThreeFragment();
|
||||||
|
b4 = new FourFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
Fragment fragment = null;
|
||||||
|
switch (position){
|
||||||
|
case MainActivity.PAGE_ONE:
|
||||||
|
fragment = b1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainActivity.PAGE_TWO:
|
||||||
|
fragment = b2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainActivity.PAGE_THREE:
|
||||||
|
fragment = b3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainActivity.PAGE_FOUR:
|
||||||
|
fragment = b4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return PAGE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package com.example.final_project_app.adpter;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
import com.example.final_project_app.db.NoteBook;
|
||||||
|
import com.example.final_project_app.db.NoteData;
|
||||||
|
import com.example.final_project_app.sql.UpdateNoteActivity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class NoteRecyAdapter extends RecyclerView.Adapter<NoteRecyAdapter.MyViewHolder> {
|
||||||
|
private List<NoteData> dataList;
|
||||||
|
private Context context;
|
||||||
|
private TextView tv_edit,tv_deledt;
|
||||||
|
|
||||||
|
public NoteRecyAdapter(List<NoteData> dataList, Context context) {
|
||||||
|
this.dataList = dataList;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
//加载布局
|
||||||
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.note_item_recy,parent,false);
|
||||||
|
MyViewHolder myViewHolder = new MyViewHolder(view);
|
||||||
|
|
||||||
|
|
||||||
|
return myViewHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||||
|
NoteData data = dataList.get(position);
|
||||||
|
holder.tv_title.setText(data.getTitle());
|
||||||
|
holder.tv_time.setText(data.getTimee());
|
||||||
|
holder.tv_content.setText(data.getContent());
|
||||||
|
|
||||||
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Dialog dg = new Dialog(context, android.R.style.ThemeOverlay_Material_Dialog_Alert);
|
||||||
|
View view = LayoutInflater.from(context).inflate(R.layout.note_dialog,null);
|
||||||
|
|
||||||
|
TextView tv_edit= view.findViewById(R.id.tv_edit);
|
||||||
|
TextView tv_delete = view.findViewById(R.id.tv_delete);
|
||||||
|
tv_edit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(context, UpdateNoteActivity.class);//跳转到更新编辑页面
|
||||||
|
intent.putExtra("data_sql",data);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tv_delete.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//删除
|
||||||
|
NoteBook noteBook = new NoteBook(context);
|
||||||
|
int row = noteBook.deleteById(data);
|
||||||
|
if (row>0){
|
||||||
|
removeData(position);
|
||||||
|
Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show();
|
||||||
|
}else {
|
||||||
|
Toast.makeText(context, "删除失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dg.setContentView(view);
|
||||||
|
dg.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//删除
|
||||||
|
private void removeData(int position) {
|
||||||
|
//从列表删除数据
|
||||||
|
dataList.remove(position);
|
||||||
|
notifyItemRemoved(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return dataList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(List<NoteData> datas) {
|
||||||
|
this.dataList = datas;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
private TextView tv_title;
|
||||||
|
private TextView tv_time;
|
||||||
|
private TextView tv_content;
|
||||||
|
|
||||||
|
public MyViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
tv_title = (TextView) itemView.findViewById(R.id.tv_title);
|
||||||
|
tv_time = (TextView) itemView.findViewById(R.id.tv_time);
|
||||||
|
tv_content = (TextView) itemView.findViewById(R.id.tv_content);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
public class CultrualData {
|
||||||
|
private String name;
|
||||||
|
private int image;
|
||||||
|
public CultrualData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
public CultrualData(String name, int imageId) {
|
||||||
|
this.name = name;
|
||||||
|
this.image = imageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "简介:" + name ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageId() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
public class Movie {
|
||||||
|
private String moviename;
|
||||||
|
private String movieuri;
|
||||||
|
public Movie(String moviename,String movieuri){
|
||||||
|
this.moviename=moviename;
|
||||||
|
this.movieuri=movieuri;
|
||||||
|
}
|
||||||
|
public String getMoviename(){
|
||||||
|
return moviename;
|
||||||
|
}
|
||||||
|
public String getMovieuri(){
|
||||||
|
return movieuri;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class NoteBook extends SQLiteOpenHelper {
|
||||||
|
private List<NoteData> dataList;
|
||||||
|
private static final String DB_NAME = "note.db";
|
||||||
|
private static final String TABLE_NAME = "notebook";
|
||||||
|
private static final String CREATE_TABLE = "create table "+
|
||||||
|
TABLE_NAME +" (id integer primary key autoincrement," +
|
||||||
|
"title text,timee text,content text)";
|
||||||
|
public NoteBook(Context context) {
|
||||||
|
super(context, DB_NAME, null, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL(CREATE_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public long insert(NoteData dt){
|
||||||
|
SQLiteDatabase sd = getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("title",dt.getTitle());
|
||||||
|
values.put("content",dt.getContent());
|
||||||
|
values.put("timee",dt.getTimee());
|
||||||
|
return sd.insert(TABLE_NAME,null,values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NoteData> query() {
|
||||||
|
List<NoteData> dtlist = new ArrayList<>();
|
||||||
|
SQLiteDatabase sd = getWritableDatabase();
|
||||||
|
Cursor cursor = sd.query(TABLE_NAME,null,null,null,null,null,null);
|
||||||
|
if (cursor!=null) {
|
||||||
|
while (cursor.moveToNext()){
|
||||||
|
@SuppressLint("Range") String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||||
|
@SuppressLint("Range") String content = cursor.getString(cursor.getColumnIndex("content"));
|
||||||
|
@SuppressLint("Range") String timee = cursor.getString(cursor.getColumnIndex("timee"));
|
||||||
|
|
||||||
|
NoteData dt_sql = new NoteData();
|
||||||
|
dt_sql.setTitle(title);
|
||||||
|
dt_sql.setContent(content);
|
||||||
|
dt_sql.setTimee(timee);
|
||||||
|
dtlist.add(dt_sql);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return dtlist;
|
||||||
|
}
|
||||||
|
//更新
|
||||||
|
public int updateByTitle(NoteData dt) {
|
||||||
|
SQLiteDatabase sd = getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("content", dt.getContent());
|
||||||
|
return sd.update(TABLE_NAME, values, "title like ?", new String[]{dt.getTitle()});
|
||||||
|
}
|
||||||
|
//删除 //调用delete语句
|
||||||
|
public int deleteById(NoteData dt){
|
||||||
|
SQLiteDatabase sd = getWritableDatabase();
|
||||||
|
return sd.delete(TABLE_NAME,"title like ?",new String[]{dt.getTitle()});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class NoteData implements Serializable {
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private String timee;
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public NoteData(String title, String content) {
|
||||||
|
this.title = title;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoteData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoteData(String title, String content, String time, String id) {
|
||||||
|
this.title = title;
|
||||||
|
this.content = content;
|
||||||
|
this.timee = time;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimee() {
|
||||||
|
return timee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimee(String timee) {
|
||||||
|
this.timee = timee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
|
public class PermissionUtiils {
|
||||||
|
//请求权限类
|
||||||
|
// Storage Permissions
|
||||||
|
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||||
|
private static String[] PERMISSIONS_STORAGE = {
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
public static void verifyStoragePermissions(Activity activity) {
|
||||||
|
// Check if we have write permission
|
||||||
|
int permission = ActivityCompat.checkSelfPermission(activity,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// We don't have permission so prompt the user
|
||||||
|
ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
|
||||||
|
REQUEST_EXTERNAL_STORAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.final_project_app.db;
|
||||||
|
|
||||||
|
public class bannerBean {
|
||||||
|
public int picture;
|
||||||
|
|
||||||
|
public bannerBean(int picture) {
|
||||||
|
this.picture = picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPicture() {
|
||||||
|
return picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPicture(int picture) {
|
||||||
|
this.picture = picture;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.example.final_project_app.entity;
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String userAccount;
|
||||||
|
private String userPassword;
|
||||||
|
private String userName;
|
||||||
|
private int userType;
|
||||||
|
private int userState;
|
||||||
|
private int userDel;
|
||||||
|
|
||||||
|
|
||||||
|
public User() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(int id, String userAccount, String userPassword, String userName, int userType, int userState, int userDel) {
|
||||||
|
this.id = id;
|
||||||
|
this.userAccount = userAccount;
|
||||||
|
this.userPassword = userPassword;
|
||||||
|
this.userName = userName;
|
||||||
|
this.userType = userType;
|
||||||
|
this.userState = userState;
|
||||||
|
this.userDel = userDel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserAccount() {
|
||||||
|
return userAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserAccount(String userAccount) {
|
||||||
|
this.userAccount = userAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserPassword() {
|
||||||
|
return userPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserPassword(String userPassword) {
|
||||||
|
this.userPassword = userPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserType(int userType) {
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserState() {
|
||||||
|
return userState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserState(int userState) {
|
||||||
|
this.userState = userState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserDel() {
|
||||||
|
return userDel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserDel(int userDel) {
|
||||||
|
this.userDel = userDel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.example.final_project_app.sql;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
import com.example.final_project_app.db.NoteBook;
|
||||||
|
import com.example.final_project_app.db.NoteData;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class AddNoteActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private NoteBook nb;
|
||||||
|
|
||||||
|
private EditText et_content,et_title;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_add_note);
|
||||||
|
et_title= (EditText) findViewById(R.id.et_title);
|
||||||
|
et_content = (EditText) findViewById(R.id.et_content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BtnAdd(View view) {
|
||||||
|
String title = et_title.getText().toString().trim();
|
||||||
|
String content = et_content.getText().toString().trim();
|
||||||
|
|
||||||
|
NoteData dt = new NoteData(title,content);
|
||||||
|
dt.setTimee(getSystemCurrentTime());
|
||||||
|
|
||||||
|
nb = new NoteBook(this);
|
||||||
|
long rowId = nb.insert(dt);
|
||||||
|
if (rowId!=-1) {
|
||||||
|
Toast.makeText(this, "添加成功", Toast.LENGTH_SHORT).show();
|
||||||
|
this.finish();
|
||||||
|
}else {
|
||||||
|
Toast.makeText(this, "添加失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSystemCurrentTime() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
|
||||||
|
Date datetime = new Date();
|
||||||
|
return sdf.format(datetime);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.example.final_project_app.sql;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.example.final_project_app.R;
|
||||||
|
import com.example.final_project_app.db.NoteBook;
|
||||||
|
import com.example.final_project_app.db.NoteData;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class UpdateNoteActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private EditText et_content,et_title;
|
||||||
|
private NoteData dt_up;
|
||||||
|
private NoteBook nb;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_update_note);
|
||||||
|
//获取控件
|
||||||
|
et_title= (EditText) findViewById(R.id.et_title);
|
||||||
|
et_content = (EditText) findViewById(R.id.et_content);
|
||||||
|
//数据接收
|
||||||
|
Intent intent = getIntent();
|
||||||
|
dt_up = (NoteData) intent.getSerializableExtra("data_sql");
|
||||||
|
if (dt_up!=null){
|
||||||
|
et_title.setText(dt_up.getTitle());
|
||||||
|
et_content.setText(dt_up.getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BtnUpdate(View view) {
|
||||||
|
String title = et_title.getText().toString().trim();
|
||||||
|
String content = et_content.getText().toString().trim();
|
||||||
|
|
||||||
|
NoteData dt = new NoteData(title,content);
|
||||||
|
dt.setTimee(getSystemCurrentTime());
|
||||||
|
|
||||||
|
nb = new NoteBook(this);
|
||||||
|
nb.updateByTitle(dt);
|
||||||
|
int row = nb.updateByTitle(dt);
|
||||||
|
if (row>0){
|
||||||
|
Toast.makeText(this, "更新成功", Toast.LENGTH_SHORT).show();
|
||||||
|
this.finish();
|
||||||
|
}else {
|
||||||
|
Toast.makeText(this, "更新失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private String getSystemCurrentTime() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
|
||||||
|
Date datetime = new Date();
|
||||||
|
return sdf.format(datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 284 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 318 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 867 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 580 KiB |
After Width: | Height: | Size: 208 KiB |
After Width: | Height: | Size: 563 KiB |
After Width: | Height: | Size: 284 KiB |
After Width: | Height: | Size: 282 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 280 KiB |
After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 315 KiB |
After Width: | Height: | Size: 492 KiB |
After Width: | Height: | Size: 420 KiB |
After Width: | Height: | Size: 440 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 657 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 330 KiB |
After Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 155 KiB |
After Width: | Height: | Size: 141 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 909 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 5.2 KiB |
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- 按钮选中状态-->
|
||||||
|
<item android:state_checked="true" android:drawable="@drawable/shape_radiobutton"></item>
|
||||||
|
<!-- 按钮未选中状态-->
|
||||||
|
<item android:state_checked="false" android:drawable="@drawable/shape_radiobutton2"></item>
|
||||||
|
</selector>
|