0

Please help me construct item for ListView. Each item of ListView contains line with TextView and EditText.

expected

So, it could also contain multiple sentences displayed in multiple lines of text. And sentence can contain several editText. On screen, layout must multiline switch auto (line break).

How I can make that?

I using predicate layout from here Line-breaking widget layout for Android

But I have problem with baseline on predicate layout:

baseline problem

xml item:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/matcher_background"
    android:orientation="vertical">

    <com.***.customviews.EditableTextView
        android:id="@+id/editable_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

public class EditableTextView extends PredicateLayout {

    protected LTTXT1Item item;

    public EditableTextView(Context context) {
        super(context);
    }

    public EditableTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void init(LTTXT1Item item) {
        this.item = item;
        removeAllViews();

        if (item.isValidItem()) {
            String[] text = item.getTextWithoutSeparators().split(LTTXT1Item.EDIT_TEXT_PLACE);

            for (String str : text) {
                final TextView textView = new TextView(getContext());
                textView.setText(str);
                addView(textView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

                final EditText editText = new EditText(getContext());
                editText.setHint("?");
                addView(editText, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            }

        } else {
            Toast.makeText(getContext(), item.toString() + " is not valid", Toast.LENGTH_SHORT).show();
        }
    }
}
Community
  • 1
  • 1
smail2133
  • 936
  • 2
  • 7
  • 24

0 Answers0