Update task to TextView protocol
This commit is contained in:
		| @@ -1,20 +1,42 @@ | ||||
| package ru.myitschool.work; | ||||
|  | ||||
| import android.os.Bundle; | ||||
| import android.text.method.ScrollingMovementMethod; | ||||
| import android.widget.Toast; | ||||
|  | ||||
| import androidx.annotation.Nullable; | ||||
| import androidx.annotation.StringRes; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|  | ||||
| import ru.myitschool.work.databinding.ActivityMainBinding; | ||||
|  | ||||
| public class MainActivity extends AppCompatActivity { | ||||
|  | ||||
|     private ActivityMainBinding binding; | ||||
|     private ArrayList<String> protocol = new ArrayList<>(); | ||||
|  | ||||
|  | ||||
|     void logLifecycleState(@StringRes int resourceId) { | ||||
|         String text = getString(resourceId); | ||||
|         protocol.add(text); | ||||
|     } | ||||
|  | ||||
|     void showLog() { | ||||
|         StringBuilder s = new StringBuilder(); | ||||
|         for (String state : protocol) { | ||||
|             s.append(state).append("\n"); | ||||
|         } | ||||
|         binding.protocol.setText(s.toString()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         final ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater()); | ||||
|         binding = ActivityMainBinding.inflate(getLayoutInflater()); | ||||
|         setContentView(binding.getRoot()); | ||||
|         Toast.makeText(this, R.string.ncreate, Toast.LENGTH_LONG).show(); | ||||
|         binding.protocol.setMovementMethod(new ScrollingMovementMethod()); | ||||
|     } | ||||
|  | ||||
|     // Добавьте недостающие методы здесь | ||||
|   | ||||
| @@ -1,13 +1,22 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <FrameLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <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:id="@+id/main" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|     android:layout_height="match_parent" | ||||
|     tools:context=".MainActivity"> | ||||
|  | ||||
|     <TextView | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_gravity="center" | ||||
|         android:text="Hello World!"/> | ||||
|  | ||||
| </FrameLayout> | ||||
|         android:id="@+id/protocol" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="0dp" | ||||
|         android:scrollbars="vertical" | ||||
|         android:text="Протокол\n" | ||||
|         android:textAlignment="center" | ||||
|         android:textSize="34sp" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" /> | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
		Reference in New Issue
	
	Block a user