0
I put a header
in my ListView
because I wanted him to roll along with her. In this header there are two EditText
, When I click on the second, the focus goes back to the first one in less than a second. There’s not even time to write anything in the second field, and whenever I click this, does anyone have any idea what it is? (I took the general code from Activity to make it smaller)
class ConfigActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.config)
var header = layoutInflater.inflate(R.layout.config_header, null)
lvOptions.addHeaderView(header)
var adapter = OptionsAdapter(this, ArrayList<Option>()) //só pra criar o adapter da listview, vazia mesmo, só com o header
lvOptions.adapter = adapter
}
}
here config_header.xml (In config.xml you only have Listview and in Adapter you have nothing relating to Header)
<?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="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/eTNome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nome"
android:inputType="textPersonName"
android:maxLines="1" />
<EditText
android:id="@+id/eTRendaM"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Renda mensal"
android:inputType="number"
android:maxLines="1" />
</LinearLayout>
In case I put my Edittext as a "Toolbar" that would "hide" when the listview der scroll down and appear again when scroll up?
– underfilho
Exactly that. Probably the flag you will use will be the
app:layout_scrollFlags="scroll|enterAlways"
. But there are some others that might suit your case.– Max Fratane
Are you sure Listview works with Appbarlayout? tried here and it didn’t work, also tried with Scrollview and did not, already with Nestedscrollview worked, I think it should only work with Recyclerview instead of Listview, I will try to implement it
– underfilho
It does. But since you’re using Recyclerview, this example here is good: https://mobikul.com/hideshow-toolbar-scrolling/
– Max Fratane