AleksandraLebedeva 1 year ago
parent
commit
bb02109f04

+ 14 - 0
app/src/main/AndroidManifest.xml

@@ -15,6 +15,20 @@
         android:supportsRtl="true"
         android:theme="@style/Theme.Test"
         tools:targetApi="31">
+        <activity
+            android:name=".Edit"
+            android:exported="false">
+            <meta-data
+                android:name="android.app.lib_name"
+                android:value="" />
+        </activity>
+        <activity
+            android:name=".Add"
+            android:exported="false">
+            <meta-data
+                android:name="android.app.lib_name"
+                android:value="" />
+        </activity>
         <activity
             android:name=".MainActivity"
             android:exported="false">

+ 14 - 0
app/src/main/java/com/example/test/Add.java

@@ -0,0 +1,14 @@
+package com.example.test;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+public class Add extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_add);
+    }
+}

+ 14 - 0
app/src/main/java/com/example/test/Edit.java

@@ -0,0 +1,14 @@
+package com.example.test;
+
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+public class Edit extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_edit);
+    }
+}

+ 30 - 6
app/src/main/java/com/example/test/MainActivity.java

@@ -4,6 +4,7 @@ import android.content.Intent;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.widget.ListView;
+import android.widget.Toast;
 
 import androidx.appcompat.app.AppCompatActivity;
 
@@ -23,18 +24,20 @@ public class MainActivity extends AppCompatActivity {
 
 
     private  AdapterMask pAdapter;
-    String usl = "https://ngknn.ru:5001/NGKNN/лебедевааф/api/Teachers";
 List<DataModal> listlist= new ArrayList<>();
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
 
+ /*
+        Для того чтобы заполнить ListView  нам необходимо создать адптер. Адаптер используется для связи данных (массивы, базы данных)
+        со списком (ListView)
+        */
 
-        //ListList = findViewById(R.id.ListList);
-        ListView ivList = findViewById(R.id.ListList);
-pAdapter = new AdapterMask(MainActivity.this, listlist );
-        ivList.setAdapter(pAdapter);
+        ListView ivList = findViewById(R.id.ListList); //Находим лист в который будем класть наши объекты
+pAdapter = new AdapterMask(MainActivity.this, listlist ); //Создаем объект нашего адаптера
+        ivList.setAdapter(pAdapter);//Cвязывает подготовленный список с адаптером
 
         List<String> list = new ArrayList<>();
         list.add("Без сортировки");
@@ -47,9 +50,11 @@ pAdapter = new AdapterMask(MainActivity.this, listlist );
         list2.add("Фамилия");
 
 
-        new GetPr().execute();
+        new GetPr().execute();//Подключение к нашей API в отдельном потоке
     }
 
+
+
     private  class  GetPr extends AsyncTask<Void, Void, String>
     {
         @Override
@@ -96,11 +101,30 @@ pAdapter = new AdapterMask(MainActivity.this, listlist );
             }
         }
     }
+public  void forAdd()
+{
+    try {
+        Intent intent = new Intent(MainActivity.this, Add.class);
+        startActivity(intent);
+    }
+    catch (Exception ex)
+    {
+        Toast.makeText(MainActivity.this, "fjgdf", Toast.LENGTH_SHORT).show();
+    }
+
+}
+
 
     public  void forBack ()
     {
+        try {
         Intent intent = new Intent(MainActivity.this, Autorezation.class);
         startActivity(intent);
+    }
+    catch (Exception ex)
+    {
+        Toast.makeText(MainActivity.this, "fjgdf", Toast.LENGTH_SHORT).show();
+    }
 
     }
 }

+ 9 - 0
app/src/main/res/layout/activity_add.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout 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"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".Add">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 9 - 0
app/src/main/res/layout/activity_edit.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout 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"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".Edit">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 10 - 0
app/src/main/res/layout/activity_main.xml

@@ -49,6 +49,16 @@
             android:id="@+id/Clear">
         </Button>
 
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Добавление"
+            android:onClick="forAdd"
+            android:gravity="center_vertical"
+            android:layout_alignParentBottom="true"
+            android:id="@+id/Add">
+        </Button>
+
         <ListView
             android:id="@+id/ListList"
             android:layout_width="match_parent"