Store EditText value in ListView

Good afternoon!

I move the ListView inside the EditText, where the user views the value entered in the EditText, changes position.

How can I do it?

I thank you!

GetView () method:

public View getView(final int position, View convertView, ViewGroup parent){

 final Sapatos sapato = lista.get(position); if (convertView == null){ LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); holder = new ViewHolder(); convertView = inflater.inflate(R.layout.list_pedidos, null); holder.img = (ImageView) convertView.findViewById(R.id.imgPed); holder.edt = (EditText)convertView.findViewById(R.id.editText1); final LinearLayout layout; layout = (LinearLayout)convertView.findViewById(R.id.LayoutPed); convertView.setTag(holder); } else{ holder = (ViewHolder) convertView.getTag(); } holder.img.setImageResource(sapato.getImagem()); holder.edt.setText(""); //adicionei somente esta linha return convertView; 

} Code>

+4
source share
1 answer

I am thinking about what you like when your Sapatos is shown as a list, and some property is changed when it is used, it performs text editing. You will miss (at least) the following:

  • Entering a list of records with Sapato data. List entries are reused, and the layout is properly inflated if the transformation is null. But you will need to configure the data from your Sapato in the fields (move all findVuewById outside if, as you need to do this anyway, and fill them in)
  • When list views are reused, you save the edited data in your Sapato as soon as the edit text loses focus.
0
source

Source: https://habr.com/ru/post/1392039/


All Articles