added stuff
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.example.generator;
|
||||
|
||||
import android.media.metrics.Event;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -13,6 +15,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Tab1 extends Fragment {
|
||||
|
||||
private static final String ARG_POSITION = "tab_position";
|
||||
@@ -28,6 +32,7 @@ public class Tab1 extends Fragment {
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
public int[] NumButtonOb = new int[9];
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -36,13 +41,26 @@ public class Tab1 extends Fragment {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_tab1, container, false);
|
||||
|
||||
|
||||
int tabPosition = getArguments() != null ? getArguments().getInt(ARG_POSITION, 0) : 0;
|
||||
|
||||
TextView elementTitle = view.findViewById(R.id.text1);
|
||||
elementTitle.setText("Element " + (tabPosition + 1));
|
||||
elementTitle.setText("Object " + (tabPosition + 1));
|
||||
NumButtonOb = EventsActivity.Data.getNumButtonOb();
|
||||
|
||||
|
||||
EditText ToAdd = view.findViewById(R.id.toAdd);
|
||||
EditText ToAdd2 = view.findViewById(R.id.toAdd2);
|
||||
EditText ToAdd3 = view.findViewById(R.id.toAdd3);
|
||||
EditText ToAdd4 = view.findViewById(R.id.toAdd4);
|
||||
EditText ToAdd5 = view.findViewById(R.id.toAdd5);
|
||||
EditText ToAdd6 = view.findViewById(R.id.toAdd6);
|
||||
EditText ToAdd7 = view.findViewById(R.id.toAdd7);
|
||||
EditText ToAdd8 = view.findViewById(R.id.toAdd8);
|
||||
EditText ToAdd9 = view.findViewById(R.id.toAdd9);
|
||||
|
||||
EditText numOfButton = view.findViewById(R.id.numOfButton);
|
||||
View[] objectives = {
|
||||
View[] buttons = {
|
||||
view.findViewById(R.id.toAdd),
|
||||
view.findViewById(R.id.toAdd2),
|
||||
view.findViewById(R.id.toAdd3),
|
||||
@@ -53,10 +71,19 @@ public class Tab1 extends Fragment {
|
||||
view.findViewById(R.id.toAdd8),
|
||||
view.findViewById(R.id.toAdd9)
|
||||
};
|
||||
for (int o = 0; o < buttons.length; o++) {
|
||||
buttons[o].setVisibility(o < NumButtonOb[tabPosition] ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (NumButtonOb[tabPosition] == 0) {
|
||||
|
||||
}else {
|
||||
numOfButton.setText(String.valueOf(NumButtonOb[tabPosition]));
|
||||
}
|
||||
|
||||
numOfButton.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
@@ -64,16 +91,36 @@ public class Tab1 extends Fragment {
|
||||
EventsActivity.Data.setNumScoreOb(input);
|
||||
|
||||
int score = input.isEmpty() ? 0 : Integer.parseInt(input);
|
||||
NumButtonOb = EventsActivity.Data.getNumButtonOb();
|
||||
NumButtonOb[tabPosition] = score;
|
||||
EventsActivity.Data.setNumButtonOb(NumButtonOb);
|
||||
Log.d("score", Arrays.toString(NumButtonOb));
|
||||
|
||||
for (int o = 0; o < objectives.length; o++) {
|
||||
objectives[o].setVisibility(o < score ? View.VISIBLE : View.GONE);
|
||||
|
||||
for (int o = 0; o < buttons.length; o++) {
|
||||
buttons[o].setVisibility(o < NumButtonOb[tabPosition] ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
|
||||
ToAdd.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user