added space to dynamic content

This commit is contained in:
JG-Cody 2021-06-27 21:10:49 +02:00
parent 055b7907c6
commit 80b1beb09d
6 changed files with 116 additions and 13 deletions

View File

@ -102,6 +102,8 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
} else if (i == 2) {
} else if (i == 3) {
listAdapter.add(new ListItemSpace(3));
listAdapter.notifyDataSetChanged();
}
@ -112,6 +114,7 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
Objects.requireNonNull(mDialog.getWindow()).setBackgroundDrawableResource(R.drawable.button_round);
mDialog.show();
}
public void openDialog1() {
list_item_type = 0;
AddButtonDialogSingle addButtonDialogSingle = new AddButtonDialogSingle();

View File

@ -18,7 +18,8 @@ public class ListAdapter extends ArrayAdapter {
public static int SINGLEBUTTON = 0;
public static int DOUBLEBUTTON = 1;
public static int OPTION3BUTTON = 2;
public static int HEADLINE = 2;
public static int SPACE = 3;
private ArrayList<ListItem> objects;
@ -26,7 +27,7 @@ public class ListAdapter extends ArrayAdapter {
@Override
public int getViewTypeCount()
{
return 3;
return 4;
}
public int getItemViewType(int position){
@ -44,7 +45,7 @@ public class ListAdapter extends ArrayAdapter {
@Override
public View getView(int position, View convertView, @NotNull ViewGroup parent) {
IViewHolder viewHolder= null;
IViewHolder viewHolder = null;
ListItem listViewItem = objects.get(position);
int listViewItemType = getItemViewType(position);
@ -64,8 +65,7 @@ public class ListAdapter extends ArrayAdapter {
//viewHolder = new ViewHolderSingleButton(bRun , listViewItem.getText());
//convertView.setTag(viewHolder);
}
else if (listViewItemType == DOUBLEBUTTON) {
} else if (listViewItemType == DOUBLEBUTTON) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.doublebutton, null);
Button bLeft = (Button) convertView.findViewById(R.id.doubleButton_bLeft);
Button bRight = (Button) convertView.findViewById(R.id.doubleButton_bRight);
@ -76,19 +76,19 @@ public class ListAdapter extends ArrayAdapter {
text.setText(s[0]);
//viewHolder = new ViewHolderDoubleButton(bLeft,bRight,listViewItem.getText());
//convertView.setTag(viewHolder);
} else if (listViewItemType == SPACE) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.space, null);
} else {
viewHolder = (IViewHolder) convertView.getTag();
}
}
else{
viewHolder = (IViewHolder) convertView.getTag();
}
return convertView;
}
return convertView;
}
}
}}

View File

@ -0,0 +1,56 @@
package de.jg_cody.Teraplex.ui.rooms;
public class ListItemHeadline extends ListItem{
private String name, command1, command2,button1, button2;
public ListItemHeadline(int type, String name, String command1, String command2, String button1, String button2) {
super( type);
this.name = name;
}
public void setName(String name)
{
this.name = name;
}
public void setCommand1(String command1)
{
this.command1 = command1;
}
public void setCommand2(String command2)
{
this.command2 = command2;
}
public void setButton1(String button1)
{
this.button1 = button1;
}
public void setButton2(String button2)
{
this.button2 = button2;
}
public String getName()
{
return name;
}
public String getCommand1()
{
return command1;
}
public String getCommand2()
{
return command2;
}
public String getButton1()
{
return button1;
}
public String getButton2()
{
return button2;
}
@Override
public String[] getStrings() {
String[] s = {name, command1, command2, button1,button2};
return s;
}
}

View File

@ -0,0 +1,16 @@
package de.jg_cody.Teraplex.ui.rooms;
public class ListItemSpace extends ListItem{
public ListItemSpace(int type) {
super( type);
}
@Override
public String[] getStrings() {
String[] s = {};
return s;
}
}

View File

@ -0,0 +1,15 @@
<?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"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/headline_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>

View File

@ -0,0 +1,13 @@
<?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"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Space
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="1" />
</LinearLayout>