Guys, I have two following problems - and I must solve them until tonight (for a school project). I know the "phooey!"s will hail on me because I waited for the last date to finish this stuff, and I'm SORRY, I'll never wait this long again!
- anyway, one of them is a layout issue: The declared EditTexts are not showing on my screen of EditableWeekActivity. These are my classes and used xml-files (I hope you can see some mistake I can't): The fixed ToolBar and days are just showing fine, but underneath those there is supposed to be eleven rows of EditTexts that will serve as something like a grid.
This is my Activity:
...the adapter class:
...and the respective xml-files that are referred to:
...this post will be too long if I add the databank issue. Nevermind that one. Please, please help! >_<
- anyway, one of them is a layout issue: The declared EditTexts are not showing on my screen of EditableWeekActivity. These are my classes and used xml-files (I hope you can see some mistake I can't): The fixed ToolBar and days are just showing fine, but underneath those there is supposed to be eleven rows of EditTexts that will serve as something like a grid.
This is my Activity:
Code:
public class EditableWeekActivity extends AppCompatActivity{
DatensatzStundenplan[] neueWerte;
DatenbankVerwalten d;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_week_edit);
d = new DatenbankVerwalten(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarEdit);
setSupportActionBar(toolbar);
final LinearLayout table = (LinearLayout) findViewById(R.id.tableRowDaysEdit);
TextView tv;
tv = (TextView) table.findViewById(R.id.day11);
tv.setText("Mo");
tv = (TextView) table.findViewById(R.id.day22);
tv.setText("Di");
tv = (TextView) table.findViewById(R.id.day33);
tv.setText("Mi");
tv = (TextView) table.findViewById(R.id.day44);
tv.setText("Do");
tv = (TextView) table.findViewById(R.id.day55);
tv.setText("Fr");
neueWerte = new DatensatzStundenplan[11];
}
private void neueFaecherEintragen(Context context) {
LayoutInflater li = LayoutInflater.from(this);
ListView weekTable = (ListView) findViewById(R.id.editableWeekTable);
ListAdapter adapter = new EditableAdapter(this, Arrays.asList(neueWerte));
weekTable.setAdapter(adapter);
}
public void speichern(View v){
neueFaecherEintragen(this);
boolean geklappt;
for(int i = 0; i<neueWerte.length; i++){
geklappt = d.insertStunde(neueWerte[i].getFachMo(), i, Wochentag.MO.name());
if(geklappt == false){
System.out.println("Speichern gescheitert - sorry!");
}
geklappt = d.insertStunde(neueWerte[i].getFachDi(), i, Wochentag.DI.name());
if(geklappt == false){
System.out.println("Speichern gescheitert - sorry!");
}
geklappt = d.insertStunde(neueWerte[i].getFachMi(), i, Wochentag.MI.name());
if(geklappt == false){
System.out.println("Speichern gescheitert - sorry!");
}
geklappt = d.insertStunde(neueWerte[i].getFachDo(), i, Wochentag.DO.name());
if(geklappt == false){
System.out.println("Speichern gescheitert - sorry!");
}
geklappt = d.insertStunde(neueWerte[i].getFachFr(), i, Wochentag.FR.name());
if(geklappt == false){
System.out.println("Speichern gescheitert - sorry!");
}
}
}
public void abbrechen(View v){
Intent i = new Intent(this, WeekActivity.class);
startActivity(i);
}
//Bei dieser Methode muss "MainActivity" mit dem Klassennamen der Startseite ersetzt werden, damit es bei der Unkommentierung keine Fehlermeldungen gibt.
public void toMainActivity(View v){
//Intent i = new Intent(this, MainActivity.class);
//startActivity(i);
}
}
...the adapter class:
Code:
public class EditableAdapter extends ArrayAdapter<DatensatzStundenplan>{
private List<DatensatzStundenplan> list;
private final Activity context;
public EditableAdapter(Activity context, List<DatensatzStundenplan> list) {
super(context, R.layout.table_row_subjects_edit, list);
this.context = context;
this.list = list;
}
static class ViewHolder {
protected TextView stunde;
protected EditText fachMontag;
protected EditText fachDienstag;
protected EditText fachMittwoch;
protected EditText fachDonnerstag;
protected EditText fachFreitag;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
final ViewHolder viewHolder = new ViewHolder();
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(R.layout.table_row_subjects_edit, parent, false);
viewHolder.fachMontag = (EditText) view.findViewById(R.id.cell_1_edit);
viewHolder.fachDienstag = (EditText) view.findViewById(R.id.cell_2_edit);
viewHolder.fachMittwoch = (EditText) view.findViewById(R.id.cell_3_edit);
viewHolder.fachDonnerstag = (EditText) view.findViewById(R.id.cell_4_edit);
viewHolder.fachFreitag = (EditText) view.findViewById(R.id.cell_5_edit);
viewHolder.stunde = (TextView) view.findViewById(R.id.stundeEdit);
/* viewHolder.button2.setOnClickListener(new Button.OnClickListener() {
// @Override
public void onClick(View v) {
//toDo
}
});*/
view.setTag(viewHolder);
viewHolder.fachMontag.setTag(list.get(position).getFachMo());
viewHolder.fachDienstag.setTag(list.get(position).getFachDi());
viewHolder.fachMittwoch.setTag(list.get(position).getFachMi());
viewHolder.fachDonnerstag.setTag(list.get(position).getFachDo());
viewHolder.fachFreitag.setTag(list.get(position).getFachFr());
} else {
view = convertView;
((ViewHolder) view.getTag()).stunde.setTag(list.get(position).getTimeslot());
((ViewHolder) view.getTag()).fachMontag.setTag(list.get(position).getFachMo());
((ViewHolder) view.getTag()).fachDienstag.setTag(list.get(position).getFachDi());
((ViewHolder) view.getTag()).fachMittwoch.setTag(list.get(position).getFachMi());
((ViewHolder) view.getTag()).fachDonnerstag.setTag(list.get(position).getFachDo());
((ViewHolder) view.getTag()).fachFreitag.setTag(list.get(position).getFachFr());
}
ViewHolder holder = (ViewHolder) view.getTag();
//StartActivity.spielerDb.open();
//Spiel sp = StartActivity.spielerDb.spielAuswaehlen(list.get(position).getSpielNr());
//if(list.get(position).getPosition().equals("Torwart")) {
holder.stunde.setText(String.valueOf(list.get(position).getTimeslot()+1)); //Laut der Liste wäre die 1. Stunde sonst "0"!
holder.fachMontag.setText(list.get(position).getFachMo());
holder.fachDienstag.setText(list.get(position).getFachDi());
holder.fachMittwoch.setText(list.get(position).getFachMi());
holder.fachDonnerstag.setText(list.get(position).getFachDo());
holder.fachFreitag.setText(list.get(position).getFachFr());
//}
//holder.checkBox1.setChecked(list.get(position).isImAktSpielerkader());
//zeilen mit abwechselnder Hintergrundfarbe
if (position % 2 == 0) {
view.setBackgroundColor(0xf0f0f0f0);
} else {
view.setBackgroundColor(0x0f0f0f00);
}
return view;
}
}
...and the respective xml-files that are referred to:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize">
<!-- android:background="@color/#..." <- Farbe rausfinden!-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/save"
android:text="Speichern"
android:onClick="speichern"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel"
android:text="Abbruch"
android:onClick="abbrechen"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/zuStartseite2"
android:text="Home"
android:onClick="toMainActivity" />
</android.support.v7.widget.Toolbar>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/editableWeekTable"
android:layout_below="@+id/tableRowDaysEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<LinearLayout
android:id="@+id/tableRowDaysEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbarEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="11">
<TextView
android:id="@+id/stundeEdit"
android:text=" "
android:textColor="#29088A"
android:textSize="@dimen/abc_text_size_large_material"
android:textAlignment="center"
android:layout_height="30dp"
android:layout_width="70dp"
android:layout_alignTop="@+id/tableRowDaysEdit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_weight="1"/>
<TextView
android:id="@+id/day11"
android:textColor="#29088A"
android:text="MO"
android:textSize="@dimen/abc_text_size_large_material"
android:gravity="center"
android:textAlignment="center"
android:layout_height="30dp"
android:layout_width="66dp"
android:layout_weight="2"/>
<TextView
android:id="@+id/day22"
android:textColor="#29088A"
android:text="DI"
android:textSize="@dimen/abc_text_size_large_material"
android:textAlignment="center"
android:gravity="center"
android:layout_height="30dp"
android:layout_width="66dp"
android:layout_weight="2"/>
<TextView
android:id="@+id/day33"
android:textColor="#29088A"
android:text="MI"
android:textSize="@dimen/abc_text_size_large_material"
android:textAlignment="center"
android:gravity="center"
android:layout_height="30dp"
android:layout_width="66dp"
android:layout_weight="2"/>
<TextView
android:id="@+id/day44"
android:textColor="#29088A"
android:text="DO"
android:textSize="@dimen/abc_text_size_large_material"
android:textAlignment="center"
android:gravity="center"
android:layout_height="30dp"
android:layout_width="66dp"
android:layout_weight="2"/>
<TextView
android:id="@+id/day55"
android:textColor="#29088A"
android:text="FR"
android:textSize="22sp"
android:textAlignment="center"
android:gravity="center"
android:layout_height="30dp"
android:layout_width="66dp"
android:layout_weight="2"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:clickable="true"
android:id="@+id/tableRowSubjectsEdit"
android:weightSum="11"
>
<TextView
android:id="@+id/stundeEdit"
android:layout_height="45dp"
android:text="Test"
android:textSize="25dp"
android:layout_width="80dp" />
<EditText
android:id="@+id/cell_1_edit"
android:layout_height="45dp"
android:text="test"
android:textSize="25dp"
android:layout_width="match_parent"
android:layout_weight="2"
/>
<EditText
android:id="@+id/cell_2_edit"
android:layout_height="45dp"
android:text="test"
android:textSize="25dp"
android:layout_width="match_parent"
android:layout_weight="2"
/>
<EditText
android:id="@+id/cell_3_edit"
android:layout_height="45dp"
android:text="test"
android:textSize="25dp"
android:layout_width="match_parent"
android:layout_weight="2"
/>
<EditText
android:id="@+id/cell_4_edit"
android:layout_height="45dp"
android:text="test"
android:textSize="25dp"
android:layout_width="match_parent"
android:layout_weight="2"
/>
<EditText
android:id="@+id/cell_5_edit"
android:layout_height="45dp"
android:text="test"
android:textSize="25dp"
android:layout_width="match_parent"
android:layout_weight="2"
/>
</LinearLayout>
...this post will be too long if I add the databank issue. Nevermind that one. Please, please help! >_<