前言:
使用Android Studio开发,SQLite数据库,dialog对话框,Intent组件交互,java动态生成组件等技术。(博客最下方有所有代码。若不想复制粘贴,可下载源码)
先展示效果图,别放弃!!
①初始课程表 | ②右上角添加课程 | ③填写信息 | ④显示课程 | ⑤长按显示详情 |
---|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
逻辑就是这么简单,程序亦是如此!
话不多说直接开始:
- 我们把整个程序拆分,按照增量模型完成项目(先完成基础,也是核心功能)。
- 先完成核心功能模块图一,再完成图二三四增加课程模块。
- 最后完成图五非核心功能模块。
- 测试每个模块之间衔接是否有bug。(我们希望是没有的,但时常事与愿违)
实现核心功能
-
第一步:从需求、设计入手。
-
一周有七天,一天有十节课。课程表结构的activity_main.xml框架设计大致如此。
-
分析架构:
-
最外层使用线性布局设置屏幕水平方向android:orientation=“horizontal”。
-
在内层使用八个GridLayout将屏幕分为八块。其中第一块是节课,后面的为周一至日。
关键点:因为是水平排列的,所以权重和宽度相关联。把每个GridLayout的宽度设置为0dp。除第一个GridLayout权值为0.5其余设为1。目的是让第一列占比低一些。
-
每一个GridLayout都设置为竖直方向android:orientation=“vertical”。目的是每一节课都是竖着往下排列的。
关键点:同理,因为是竖直排列的,所以权重和高度有关。把每个GridLayout的高度设置为0dp。除第一个GridLayout权值为0.25其余设为1。目的是让第一行占比低一些。
-
分析有了,上activity_main.xml代码:
-
-
- 发现xml并没有像图一有课程框。可以直接在activity_main.xml中依次添加,但是考虑到有7×10个EditText需要弄,还需要为每个EditText设置id(这个id之后非常关键),而且在xml写死的话对后期拓展(课程数量增加、减少、重构)很不便。所以我使用java在MainActivity中动态添加课程框。
public class MainActivity extends AppCompatActivity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //动态渲染课程框 framework(); } public void framework() { //创建一个GridLayout对象 GridLayout gridLayout; //定义每个框的id,之后会动态改变id值 int id = 1; //渲染每一列(周) for (int i = 1; i < 8; i++) { //注入GridLayout对应的列,根据星期几调用LayoutColumn方法 gridLayout = LayoutColumn(i); //渲染每一行(节课) for (int j = 1; j < 10; j +=2) { //声明一个新的TextView TextView textView1 = new TextView(this); //给TextView设置style样式 textView1.setId(id++); textView1.setText(""); textView1.setMaxLines(5); textView1.setEllipsize(TextUtils.TruncateAt.END); textView1.setBackgroundColor(Color.parseColor("#F0FFFF")); textView1.setGravity(Gravity.CENTER); //GridLayout.LayoutParams设置在此gridLayout列中TextView布局 GridLayout.LayoutParams params1 = new GridLayout.LayoutParams(); params1.setMargins(5,10,5,10); params1.width = GridLayout.LayoutParams.MATCH_PARENT; params1.height = 0; //设置在gridLayout中的方位,参数1:在第几行。参数2:占几行。参数3:权值 //这个权值是根据xml中第一个gridLayout节课权值设定的。 params1.rowSpec = GridLayout.spec( j, 2,1); //把TextView和布局样式添加到此gridLayout中 gridLayout.addView(textView1, params1); } } } public GridLayout LayoutColumn(int i) { //防止空指针操作 GridLayout gridLayout = findViewById(R.id.d1); //参数i:星期几。根据i寻找xml对应的GridLayout并注入。 switch (i) { case 1: { gridLayout = findViewById(R.id.d1); break; } case 2: { gridLayout = findViewById(R.id.d2); break; } case 3: { gridLayout = findViewById(R.id.d3); break; } case 4: { gridLayout = findViewById(R.id.d4); break; } case 5: { gridLayout = findViewById(R.id.d5); break; } case 6: { gridLayout = findViewById(R.id.d6); break; } case 7: { gridLayout = findViewById(R.id.d7); break; } } return gridLayout; } }
这样我们就完成了图一。
-
-
第二步:有了基础架构,开始实现功能。
-
把信息填写好了,如何保存?
-
此时,需要考虑的是如何映射数据关系,即当需要添加课程,该如何定位到我选择的位置?这时候上面我们动态设置的id的作用就显示出来了。上述id是从1开始往下依次增加到36(7天×5节课)。可以通过星期几和第几节课算出对应该课程 id。
-
最后,如何把填写的课程数据渲染到图一?
我们依次解决上述问题:
我们填写完课程信息后,把信息保存在SQLite中,重新加载MainActivity并渲染数据到课程表。
- 使用SLQLite数据库保存课程信息,SQLite数据库会存放在安卓手机内(具体介绍CSDN很多就不赘述)。
在MainActivity类同级目录创建DBHelper类(建classes_db表):
public class DBHelper extends SQLiteOpenHelper { public SQLiteDatabase getWritableDatabase() { return super.getWritableDatabase(); } public DBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); } @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { sqLiteDatabase.execSQL("create table classes_db" + "(c_id Integer not null primary key autoincrement," + " c_name varchar(50) not null," + " c_time varchar(50) not null," + " c_day varchar(50) not null," + " c_teacher varchar(50) not null)"); // 创建ContentValue设置参数 ContentValues contentValues = new ContentValues(); //课程名字 contentValues.put("c_name", "0"); //第几节课 contentValues.put("c_time", "0"); //星期几 contentValues.put("c_day", "0"); //任课教师 contentValues.put("c_teacher", "0"); //插入id 1-36 个课程数据,以便添加课程 for (int i = 1; i < 37; i++) { contentValues.put("c_id", i); sqLiteDatabase.insert("classes_db", "", contentValues); } } @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { } }
- 注意要在AndroidManifest.xml注册activity(不懂在哪粘贴不要紧,最后有全部代码):
<activity android:name=".DialogModal" android:theme="@android:style/Theme.Dialog" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
这时候就有一个classes_db表,有id分别为1-36记录存放对应课程数据。(这个id对应上述EditText的id)
-
-
添加课程dialog对话框(图二)用于把数据存放到上述classes_db表中:
在activity_main.xml同级目录下创建activity_set.xml:
这里就不赘述基础了0.0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MyModelSetting"
android:layout_width="300dp"
android:layout_height="450dp"
android:background="#fff"
android:orientation="vertical"
tools:context=".DialogModal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加课程"
android:textSize="40dp"
android:layout_gravity="center"
android:textColor="@color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="时间:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<Spinner
android:id="@+id/selected_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/day">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="节课:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<Spinner
android:id="@+id/selected_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/time">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="科目:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<EditText
android:id="@+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任课教师:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<EditText
android:id="@+id/teacher"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<Button
android:id="@+id/close_activity"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="取消" />
<Button
android:id="@+id/save_activity"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="保存" />
</LinearLayout>
</LinearLayout>
在MainActivity类同级目录创建DialogModal类,处理课程数据,保存在数据库,并跳回MainActivity:
public class DialogModal extends Activity {
Button close_activity;
Button save_activity;
Spinner selected_time;
Spinner selected_day;
EditText subject;
EditText teacher;
//数据库名,表名
public final String DB_NAME = "classes_db.db";
public final String TABLE_NAME = "classes_db";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_set);
//当点击dialog之外完成此activity
setFinishOnTouchOutside (true);
//关闭按钮操作
close_activity=(Button) findViewById(R.id.close_activity);
close_activity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogModal.this.finish();
}
});
//保存按钮操作
save_activity = findViewById(R.id.save_activity);
save_activity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
selected_day = findViewById(R.id.selected_day);
String day = selected_day.getSelectedItem().toString();
if (day.equals("--请选择--")) {
save_activity.setError("");
return;
}
selected_time = findViewById(R.id.selected_time);
String time = selected_time.getSelectedItem().toString();
if (time.equals("--请选择--")) {
save_activity.setError("");
return;
}
subject = findViewById(R.id.subject);
String text = subject.getText().toString();
if ("".equals(text)) {
save_activity.setError("");
return;
}
teacher = findViewById(R.id.teacher);
String teacher = subject.getText().toString();
if ("".equals(teacher)) {
save_activity.setError("");
return;
}
//创建一个数据库对象,为了更新数据
DBHelper dbHelper = new DBHelper(DialogModal.this, DB_NAME, null, 1);
//把数据存在contentValues中
ContentValues contentValues = new ContentValues();
//combineId()方法目的是通过星期几和第几节课算出对应该课程id
contentValues.put("c_id", combineId(day, time));
contentValues.put("c_name", text);
contentValues.put("c_time", time);
contentValues.put("c_day", day);
contentValues.put("c_teacher", teacher);
//更新数据库记录
update(dbHelper, contentValues);
//清空栈内所有activity
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TASK);
//启动MainActivity
intent.setClass(DialogModal.this, MainActivity.class);
startActivity(intent);
}
});
}
public String combineId(String day, String time) {
//星期几转换成int类型
int day1 = utils.getDay(day);
//如1-2节课只取1
int time1 = Integer.parseInt(time.substring(0, 1));
return String.valueOf((day1 - 1) * 5 + ((time1 - 1)/2 + 1));
}
public void update(DBHelper dbHelper, ContentValues contentValues){
String []a = {
contentValues.get("c_id").toString()};
// 通过DBHelper类获取一个读写的SQLiteDatabase对象
SQLiteDatabase db=dbHelper.getWritableDatabase();
// 修改数据
// 参数1:tablename
// 参数2:修改的值
// 参数3:修改的条件(SQL where语句)
// 参数4:表示whereClause语句中的表达式的占位符参数列表,这些字符串会替换where条件中?
db.update(TABLE_NAME,contentValues,"c_id=?", a);
// 释放连接
db.close();
}
}
现在问题又来了,如何从图一过渡到图二?
- 细心的小伙伴已经看到右上角的+号了!
在res文件夹下创建menu文件夹,创建menu.xml:
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_menu"
android:title="添加课程"
android:icon="@android:drawable/ic_input_add"
app:showAsAction="ifRoom">
</item>
</menu>
在MainActivity类中重写onCreateOptionsMenu方法:(Intent就是为了activity跳转)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem menuItem=menu.findItem(R.id.action_menu);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, DialogModal.class);
startActivity(intent);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
这样+号就出现了,就可以连接图一图二了!
更新MainActivity,先看onCreate方法增加的调用。
public class MainActivity extends AppCompatActivity implements View.OnTouchListener {
public final String DB_NAME = "classes_db.db";
public final String TABLE_NAME = "classes_db";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// getSupportActionBar().hide();
//拿到数据库对象,为了读取数据
DBHelper dbHelper = new DBHelper(MainActivity.this, DB_NAME, null, 1);
//动态渲染课程框
framework();
//将数据库课程渲染到课程框
applyDraw(dbHelper);
}
public void applyDraw(DBHelper dbHelper) {
//从数据库拿到课程数据保存在链表
List<Classes> classes = query(dbHelper);
for (Classes aClass : classes) {
//第几节课
int i = Integer.parseInt(aClass.getC_time().charAt(0) + "");
//星期几
int j = utils.getDay(aClass.getC_day());
//获取此课程对应TextView的id
TextView Class = findViewById((j - 1) * 5 + ((i - 1)/2 + 1));
//判断如果课程星期==当前星期,如此课程信息和当前都是星期二就把背景颜色更换。
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE");
if (aClass.getC_day().equals(simpleDateFormat.format(date).toString())) {
Class.setBackgroundColor(Color.rgb(28, 217, 204));
}
//课程表信息映射出来
Class.setText(aClass.getC_name());
//触碰此课程框触发
Class.setOnTouchListener(this);
}
}
@SuppressLint("Range")
public List<Classes> query(DBHelper dbHelper) {
List<Classes> classes = new ArrayList<>();
// 通过DBHelper类获取一个读写的SQLiteDatabase对象
SQLiteDatabase db = dbHelper.getWritableDatabase();
// 参数1:table_name
// 参数2:columns 要查询出来的列名。相当于 select *** from table语句中的 ***部分
// 参数3:selection 查询条件字句,在条件子句允许使用占位符“?”表示条件值
// 参数4:selectionArgs :对应于 selection参数 占位符的值
// 参数5:groupby 相当于 select *** from table where && group by ... 语句中 ... 的部分
// 参数6:having 相当于 select *** from table where && group by ...having %%% 语句中 %%% 的部分
// 参数7:orderBy :相当于 select ***from ?? where&& group by ...having %%% order by@@语句中的@@ 部分,如: personid desc(按person 降序)
Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, null);
// 将游标移到开头
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
// 游标只要不是在最后一行之后,就一直循环
if (!cursor.getString(cursor.getColumnIndex("c_day")).equals("0")) {
Classes Class = new Classes();
Class.setC_id(Integer.parseInt(cursor.getString(cursor.getColumnIndex("c_id"))));
Class.setC_name(cursor.getString(cursor.getColumnIndex("c_name")));
Class.setC_time(cursor.getString(cursor.getColumnIndex("c_time")));
Class.setC_day(cursor.getString(cursor.getColumnIndex("c_day")));
classes.add(Class);
}
// 将游标移到下一行
cursor.moveToNext();
}
db.close();
return classes;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem menuItem=menu.findItem(R.id.action_menu);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, DialogModal.class);
startActivity(intent);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
}
至此,核心功能就完成了!
实现非功能需求
在MainActivity类中重写此方法(注意我们已经在applyDraw方法最后一行中注册了课程框的onTouch监听):
@SuppressLint("Range")
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_DOWN: {
TextView textView = (TextView) view;
DBHelper dbHelper = new DBHelper(MainActivity.this, DB_NAME, null, 1);
SQLiteDatabase db = dbHelper.getWritableDatabase();
// 参数1:table_name
// 参数2:columns 要查询出来的列名。相当于 select *** from table语句中的 ***部分
// 参数3:selection 查询条件字句,在条件子句允许使用占位符“?”表示条件值
// 参数4:selectionArgs :对应于 selection参数 占位符的值
// 参数5:groupby 相当于 select *** from table where && group by ... 语句中 ... 的部分
// 参数6:having 相当于 select *** from table where && group by ...having %%% 语句中 %%% 的部分
// 参数7:orderBy :相当于 select ***from ?? where&& group by ...having %%% order by@@语句中的@@ 部分,如: personid desc(按person 降序)
// Cursor cursor = db.query(TABLE_NAME, null, "c_id=?", new String[]{String.valueOf(textView.getId())}, null, null, null);
Cursor cursor = db.query(TABLE_NAME, null, "c_id=?", new String[]{
String.valueOf(textView.getId())}, null, null, null);
// 将游标移到开头
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
Classes Class = new Classes();
System.out.println(textView.getId());
System.out.println(cursor.getString(cursor.getColumnIndex("c_name")));
Intent intent = new Intent();
intent.putExtra("name", cursor.getString(cursor.getColumnIndex("c_name")));
intent.putExtra("time", cursor.getString(cursor.getColumnIndex("c_time")));
intent.putExtra("day", cursor.getString(cursor.getColumnIndex("c_day")));
intent.putExtra("teacher", cursor.getString(cursor.getColumnIndex("c_teacher")));
intent.setClass(MainActivity.this, Detail.class);
startActivity(intent);
}
return true;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
break;
}
}
return false;
}
上所有代码:
- 项目结构:
根据项目结构从上到下排序
Classes类:
public class Classes {
private int c_id;
private String c_name;
private String c_time;
private String c_day;
@Override
public String toString() {
return "Classes{" +
"c_id=" + c_id +
", c_name='" + c_name + '\'' +
", c_time='" + c_time + '\'' +
", c_day='" + c_day + '\'' +
'}';
}
public int getC_id() {
return c_id;
}
public void setC_id(int c_id) {
this.c_id = c_id;
}
public String getC_name() {
return c_name;
}
public void setC_name(String c_name) {
this.c_name = c_name;
}
public String getC_time() {
return c_time;
}
public void setC_time(String c_time) {
this.c_time = c_time;
}
public String getC_day() {
return c_day;
}
public void setC_day(String c_day) {
this.c_day = c_day;
}
}
DBHelper类:
public class DBHelper extends SQLiteOpenHelper {
public SQLiteDatabase getWritableDatabase() {
return super.getWritableDatabase();
}
public DBHelper(@Nullable Context context,
@Nullable String name,
@Nullable SQLiteDatabase.CursorFactory factory,
int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("create table classes_db" +
"(c_id Integer not null primary key autoincrement," +
" c_name varchar(50) not null," +
" c_time varchar(50) not null," +
" c_day varchar(50) not null," +
" c_teacher varchar(50) not null)");
// 创建ContentValue设置参数
ContentValues contentValues = new ContentValues();
//课程名字
contentValues.put("c_name", "0");
//第几节课
contentValues.put("c_time", "0");
//星期几
contentValues.put("c_day", "0");
//任课教师
contentValues.put("c_teacher", "0");
//插入id 1-36 个课程数据,以便添加课程
for (int i = 1; i < 37; i++) {
contentValues.put("c_id", i);
sqLiteDatabase.insert("classes_db", "", contentValues);
}
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
Detail类:
public class Detail extends Activity {
TextView time;
TextView clsNum;
TextView sub;
TextView teacher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_press);
Intent intent = getIntent();
sub = findViewById(R.id.sub);
sub.setText(intent.getStringExtra("name"));
time = findViewById(R.id.time);
time.setText(intent.getStringExtra("day"));
clsNum = findViewById(R.id.clsNum);
clsNum.setText(intent.getStringExtra("time"));
teacher = findViewById(R.id.teacher);
teacher.setText(intent.getStringExtra("teacher"));
setFinishOnTouchOutside(true);
}
}
DialogModal类:
public class DialogModal extends Activity {
Button close_activity;
Button save_activity;
Spinner selected_time;
Spinner selected_day;
EditText subject;
EditText teacher;
//数据库名,表名
public final String DB_NAME = "classes_db.db";
public final String TABLE_NAME = "classes_db";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_set);
//当点击dialog之外完成此activity
setFinishOnTouchOutside (true);
//关闭按钮操作
close_activity=(Button) findViewById(R.id.close_activity);
close_activity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogModal.this.finish();
}
});
//保存按钮操作
save_activity = findViewById(R.id.save_activity);
save_activity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
selected_day = findViewById(R.id.selected_day);
String day = selected_day.getSelectedItem().toString();
if (day.equals("--请选择--")) {
save_activity.setError("");
return;
}
selected_time = findViewById(R.id.selected_time);
String time = selected_time.getSelectedItem().toString();
if (time.equals("--请选择--")) {
save_activity.setError("");
return;
}
subject = findViewById(R.id.subject);
String text = subject.getText().toString();
if ("".equals(text)) {
save_activity.setError("");
return;
}
teacher = findViewById(R.id.teacher);
String teacher = subject.getText().toString();
if ("".equals(teacher)) {
save_activity.setError("");
return;
}
//创建一个数据库对象
DBHelper dbHelper = new DBHelper(DialogModal.this, DB_NAME, null, 1);
//把数据存在contentValues中
ContentValues contentValues = new ContentValues();
//combineId()方法目的是通过星期几和第几节课算出对应该课程id
contentValues.put("c_id", combineId(day, time));
contentValues.put("c_name", text);
contentValues.put("c_time", time);
contentValues.put("c_day", day);
contentValues.put("c_teacher", teacher);
//更新数据库记录
update(dbHelper, contentValues);
//清空栈内所有activity
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TASK);
//启动MainActivity
intent.setClass(DialogModal.this, MainActivity.class);
startActivity(intent);
}
});
}
public String combineId(String day, String time) {
//星期几转换成int类型
int day1 = utils.getDay(day);
//如1-2节课只取1
int time1 = Integer.parseInt(time.substring(0, 1));
return String.valueOf((day1 - 1) * 5 + ((time1 - 1)/2 + 1));
}
public void update(DBHelper dbHelper, ContentValues contentValues){
String []a = {
contentValues.get("c_id").toString()};
// 通过DBHelper类获取一个读写的SQLiteDatabase对象
SQLiteDatabase db=dbHelper.getWritableDatabase();
// 修改数据
// 参数1:tablename
// 参数2:修改的值
// 参数3:修改的条件(SQL where语句)
// 参数4:表示whereClause语句中的表达式的占位符参数列表,这些字符串会替换where条件中?
db.update(TABLE_NAME,contentValues,"c_id=?", a);
// 释放连接
db.close();
}
}
MainActivity类:
public class MainActivity extends AppCompatActivity implements View.OnTouchListener {
public final String DB_NAME = "classes_db.db";
public final String TABLE_NAME = "classes_db";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// getSupportActionBar().hide();
//拿到数据库对象,为了读取数据
DBHelper dbHelper = new DBHelper(MainActivity.this, DB_NAME, null, 1);
//动态渲染课程框
framework();
//将数据库课程渲染到课程框
applyDraw(dbHelper);
}
public GridLayout LayoutColumn(int i) {
GridLayout gridLayout = findViewById(R.id.d1);
switch (i) {
case 1: {
gridLayout = findViewById(R.id.d1);
break;
}
case 2: {
gridLayout = findViewById(R.id.d2);
break;
}
case 3: {
gridLayout = findViewById(R.id.d3);
break;
}
case 4: {
gridLayout = findViewById(R.id.d4);
break;
}
case 5: {
gridLayout = findViewById(R.id.d5);
break;
}
case 6: {
gridLayout = findViewById(R.id.d6);
break;
}
case 7: {
gridLayout = findViewById(R.id.d7);
break;
}
}
return gridLayout;
}
public void framework() {
GridLayout gridLayout;
int id = 1;
for (int i = 1; i < 8; i++) {
gridLayout = LayoutColumn(i);
for (int j = 1; j < 10; j +=2) {
TextView textView1 = new TextView(this);
textView1.setId(id++);
textView1.setText("");
textView1.setMaxLines(5);
textView1.setEllipsize(TextUtils.TruncateAt.END);
textView1.setBackgroundColor(Color.parseColor("#F0FFFF"));
textView1.setGravity(Gravity.CENTER);
GridLayout.LayoutParams params1 = new GridLayout.LayoutParams();
params1.rowSpec = GridLayout.spec( j, 2,1);
params1.setMargins(5,10,5,10);
params1.width = GridLayout.LayoutParams.MATCH_PARENT;
params1.height = 0;
gridLayout.addView(textView1, params1);
}
}
}
public void applyDraw(DBHelper dbHelper) {
//从数据库拿到课程数据保存在链表
List<Classes> classes = query(dbHelper);
for (Classes aClass : classes) {
//第几节课
int i = Integer.parseInt(aClass.getC_time().charAt(0) + "");
//星期几
int j = utils.getDay(aClass.getC_day());
//获取此课程对应TextView的id
TextView Class = findViewById((j - 1) * 5 + ((i - 1)/2 + 1));
//判断如果课程星期==当前星期,如此课程信息和当前都是星期二就把背景颜色更换。
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE");
if (aClass.getC_day().equals(simpleDateFormat.format(date).toString())) {
Class.setBackgroundColor(Color.rgb(28, 217, 204));
}
//课程表信息映射出来
Class.setText(aClass.getC_name());
//触碰此课程框触发
Class.setOnTouchListener(this);
}
}
@SuppressLint("Range")
public List<Classes> query(DBHelper dbHelper) {
List<Classes> classes = new ArrayList<>();
// 通过DBHelper类获取一个读写的SQLiteDatabase对象
SQLiteDatabase db = dbHelper.getWritableDatabase();
// 参数1:table_name
// 参数2:columns 要查询出来的列名。相当于 select *** from table语句中的 ***部分
// 参数3:selection 查询条件字句,在条件子句允许使用占位符“?”表示条件值
// 参数4:selectionArgs :对应于 selection参数 占位符的值
// 参数5:groupby 相当于 select *** from table where && group by ... 语句中 ... 的部分
// 参数6:having 相当于 select *** from table where && group by ...having %%% 语句中 %%% 的部分
// 参数7:orderBy :相当于 select ***from ?? where&& group by ...having %%% order by@@语句中的@@ 部分,如: personid desc(按person 降序)
Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, null);
// 将游标移到开头
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
// 游标只要不是在最后一行之后,就一直循环
if (!cursor.getString(cursor.getColumnIndex("c_day")).equals("0")) {
Classes Class = new Classes();
Class.setC_id(Integer.parseInt(cursor.getString(cursor.getColumnIndex("c_id"))));
Class.setC_name(cursor.getString(cursor.getColumnIndex("c_name")));
Class.setC_time(cursor.getString(cursor.getColumnIndex("c_time")));
Class.setC_day(cursor.getString(cursor.getColumnIndex("c_day")));
classes.add(Class);
}
// 将游标移到下一行
cursor.moveToNext();
}
db.close();
return classes;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem menuItem=menu.findItem(R.id.action_menu);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, DialogModal.class);
startActivity(intent);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
@SuppressLint("Range")
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_DOWN: {
TextView textView = (TextView) view;
DBHelper dbHelper = new DBHelper(MainActivity.this, DB_NAME, null, 1);
SQLiteDatabase db = dbHelper.getWritableDatabase();
// 参数1:table_name
// 参数2:columns 要查询出来的列名。相当于 select *** from table语句中的 ***部分
// 参数3:selection 查询条件字句,在条件子句允许使用占位符“?”表示条件值
// 参数4:selectionArgs :对应于 selection参数 占位符的值
// 参数5:groupby 相当于 select *** from table where && group by ... 语句中 ... 的部分
// 参数6:having 相当于 select *** from table where && group by ...having %%% 语句中 %%% 的部分
// 参数7:orderBy :相当于 select ***from ?? where&& group by ...having %%% order by@@语句中的@@ 部分,如: personid desc(按person 降序)
// Cursor cursor = db.query(TABLE_NAME, null, "c_id=?", new String[]{String.valueOf(textView.getId())}, null, null, null);
Cursor cursor = db.query(TABLE_NAME, null, "c_id=?", new String[]{
String.valueOf(textView.getId())}, null, null, null);
// 将游标移到开头
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
Classes Class = new Classes();
System.out.println(textView.getId());
System.out.println(cursor.getString(cursor.getColumnIndex("c_name")));
Intent intent = new Intent();
intent.putExtra("name", cursor.getString(cursor.getColumnIndex("c_name")));
intent.putExtra("time", cursor.getString(cursor.getColumnIndex("c_time")));
intent.putExtra("day", cursor.getString(cursor.getColumnIndex("c_day")));
intent.putExtra("teacher", cursor.getString(cursor.getColumnIndex("c_teacher")));
intent.setClass(MainActivity.this, Detail.class);
startActivity(intent);
}
return true;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
break;
}
}
return false;
}
}
utils类:
public class utils {
public static int getDay(String day) {
int j = 0;
switch (day) {
case "星期一":{
j = 1;
break;
}
case "星期二":{
j = 2;
break;
}
case "星期三":{
j = 3;
break;
}
case "星期四":{
j = 4;
break;
}
case "星期五":{
j = 5;
break;
}
case "星期六":{
j = 6;
break;
}
case "星期日":{
j = 7;
break;
}
}
return j;
}
}
activity_main.xml:
<?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="horizontal">
<GridLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text=""
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="2"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="3"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="4"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="5"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="6"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="7"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="8"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="9"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:text="10"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周一"
android:textSize="20sp"
android:autoSizeMaxTextSize="30sp"
android:autoSizeMinTextSize="5sp"
android:autoSizeStepGranularity="1sp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周二"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周三"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周四"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周五"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFFAFA"
android:rowCount="11"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周六"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
<GridLayout
android:id="@+id/d7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:rowCount="11"
android:background="#FFFAFA"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_rowWeight="0.25"
android:text="周日"
android:textSize="20dp"
android:gravity="center"/>
</GridLayout>
</LinearLayout>
activity_press.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MyModelSetting"
android:layout_width="300dp"
android:layout_height="450dp"
android:background="#fff"
android:orientation="vertical"
tools:context=".DialogModal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="课程详情"
android:textSize="40dp"
android:layout_gravity="center"
android:textColor="@color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="时间:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="节课:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/clsNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="科目:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任课教师:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/teacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="30sp"
android:autoSizeMaxTextSize="30sp"
android:autoSizeMinTextSize="5sp"
android:autoSizeStepGranularity="1sp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
</LinearLayout>
</LinearLayout>
activity_set.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MyModelSetting"
android:layout_width="300dp"
android:layout_height="450dp"
android:background="#fff"
android:orientation="vertical"
tools:context=".DialogModal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加课程"
android:textSize="40dp"
android:layout_gravity="center"
android:textColor="@color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="时间:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<Spinner
android:id="@+id/selected_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/day">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="节课:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<Spinner
android:id="@+id/selected_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/time">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="科目:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<EditText
android:id="@+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任课教师:"
android:textSize="30dp"
android:textColor="@color/cardview_dark_background"
android:layout_margin="10dp"/>
<EditText
android:id="@+id/teacher"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<Button
android:id="@+id/close_activity"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="取消" />
<Button
android:id="@+id/save_activity"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="保存" />
</LinearLayout>
</LinearLayout>
menu.xml
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_menu"
android:title="添加课程"
android:icon="@android:drawable/ic_input_add"
app:showAsAction="ifRoom">
</item>
</menu>
strings.xml:
<resources>
<string name="app_name">schedule</string>
<string-array name="day">
<item>
--请选择--
</item>
<item>
星期一
</item>
<item>
星期二
</item>
<item>
星期三
</item>
<item>
星期四
</item>
<item>
星期五
</item>
<item>
星期六
</item>
<item>
星期日
</item>
</string-array>
<string-array name="time">
<item>
--请选择--
</item>
<item>
1-2节课
</item>
<item>
3-4节课
</item>
<item>
5-6节课
</item>
<item>
7-8节课
</item>
<item>
9-10节课
</item>
</string-array>
</resources>
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="dayStyle">
<item name="android:layout_width">48dp</item>
<item name="android:layout_height">30dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
<item name="android:background">#e9e9e9</item>
<item name="android:textSize">20dp</item>
</style>
<style id="c" name="numb">
<item name="android:layout_width">20dp</item>
<item name="android:layout_height">70dp</item>
<item name="android:gravity">center</item>
<item name="android:layout_gravity">center</item>
<item name="android:textSize">15dp</item>
<item name="android:background">#e9e9e9</item>
</style>
<dimen name="text_width">40dp</dimen>
<dimen name="text_height">130dp</dimen>
<dimen name="text_size">10dp</dimen>
<style name="Class">
<item name="android:layout_margin">5dp</item>
<item name="android:layout_width">42dp</item>
<item name="android:layout_height">130dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
<item name="android:layout_rowSpan">2</item>
<item name="android:textSize">12dp</item>
</style>
<style name="MyModelSetting" parent="Theme.AppCompat">
<!--背景色,此处的背景色请一定要设置为透明度背景色-->
<item name="android:windowBackground">@color/transparent</item>
<!--window Is Translucent 窗口是半透明的-->
<item name="android:windowIsTranslucent">true</item>
<!--window No Title窗口无标题-->
<item name="android:windowNoTitle">true</item>
<!--弹出动画-->
<item name="android:windowAnimationStyle">@null</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.schedule">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Schedule">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DialogModal"
android:theme="@android:style/Theme.Dialog"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Detail"
android:theme="@android:style/Theme.Dialog"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>