Note that there are some explanatory texts on larger screens.

plurals
  1. POListview loses the value of the editText when scrolled
    primarykey
    data
    text
    <p>Hi can anyone please help me with this one? I am using a custom adapter for populating my listview. My listview has hashmap that holds an editText. My problem is when I enter something on the editText and scroll the listview, the content of the editText lost. What should I do?Please help me I'm currently stack in it. Below shows my code:</p> <pre><code>************* myCustomAdapterIreport = new CustomArrayAdapterIreport(getApplicationContext(), mylist, R.layout.attribute_selected_ireport_file, new String[]{FILE_NAME, DESC, UPLOADED_BY, DATE_UPLOADED, ACTION, ID, FILE_URI}, new int[]{R.id.tv_iFile, R.id.txt_iDesc,R.id.tv_iUploadedBy,R.id.tv_iDateUploaded, R.id.tv_iAction, R.id.tv_RowId, R.id.tv_iUri}, true); lv_AttachedFileData.setAdapter(myCustomAdapterIreport); *********************** public class CustomArrayAdapterIreport extends SimpleAdapter { private Context context; private final ArrayList&lt;HashMap&lt;String, String&gt;&gt; mData; private ArrayList&lt;HashMap&lt;String, String&gt;&gt; unfilteredValues; private boolean chosenValues, ismarkAll = true; private int resource; private String[] from; private int[] to; private SimpleFilter mFilter; private ArrayList&lt;String&gt; arraylistAttach, arraylistAttachId; S_10th_IReportMain iReport; public CustomArrayAdapterIreport(Context context, ArrayList&lt;HashMap&lt;String, String&gt;&gt; data, int resource, String[] from, int[] to, boolean chosenValues) { super(context, data, resource, from, to); this.context = context; mData = data; this.unfilteredValues = mData; this.resource = resource; this.from = from; this.to = to; this.arraylistAttach = new ArrayList&lt;String&gt;(); this.arraylistAttachId = new ArrayList&lt;String&gt;(); this.chosenValues = chosenValues; } @Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); View rowView = null; if(rowView == null) { try{ rowView = inflater.inflate(resource, null, true); textViewTitle = (TextView) rowView.findViewById(to[0]); txt_Desc = (EditText) rowView.findViewById(to[1]); tv_CreatedBy = (TextView) rowView.findViewById(to[2]); tv_DateCreated= (TextView) rowView.findViewById(to[3]); final TextView tv_Action = (TextView) rowView.findViewById(to[4]); final TextView tv_rowId = (TextView) rowView.findViewById(to[5]); tv_Uri = (TextView)rowView.findViewById(to[6]); Typeface tf= Typeface.createFromAsset(context.getAssets(), "Gothic_Regular.TTF"); textViewTitle.setTypeface(tf); txt_Desc.setTypeface(tf); tv_CreatedBy.setTypeface(tf); tv_DateCreated.setTypeface(tf); tv_Action.setTypeface(tf); final String FileKey = from[0]; String DescKey = from[1]; String UploadedByKey = from[2]; String DateUploadKey = from[3]; String ActionKey = from[4]; final String idKey = from[5]; String FileUri = from[6]; final String FileName = unfilteredValues.get(position).get(FileKey).toString(); String Desc = unfilteredValues.get(position).get(DescKey).toString(); String UploadedBy = unfilteredValues.get(position).get(UploadedByKey).toString(); String DateUpload = unfilteredValues.get(position).get(DateUploadKey).toString(); String Action = unfilteredValues.get(position).get(ActionKey).toString(); String AttachId = unfilteredValues.get(position).get(idKey).toString(); String FileNameUri = unfilteredValues.get(position).get(FileUri).toString(); textViewTitle.setText(FileName); txt_Desc.setText(Desc); tv_CreatedBy.setText(UploadedBy); tv_DateCreated.setText(DateUpload); tv_Action.setText(Action); tv_rowId.setText(AttachId); tv_Uri.setText(FileNameUri); textViewTitle.setId(position); txt_Desc.setId(position); tv_CreatedBy.setId(position); tv_DateCreated.setId(position); tv_Uri.setId(position); final String id = tv_rowId.getText().toString(); tv_Action.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(S_10th_IReportMain.this); builder .setTitle("Warning!") .setMessage("Are you sure you want delete this file?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { deleteMyFilesiReport(position); Toast.makeText(getApplicationContext(), "Deleted", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } }); }catch (Exception e){ e.printStackTrace(); } catch (OutOfMemoryError E){ E.printStackTrace(); } } return rowView; } public ArrayList&lt;String&gt; getArrayListConsumer() { return this.arraylistAttach; } public ArrayList&lt;String&gt; getArrayListConsumerId() { return this.arraylistAttachId; } public Filter getFilter() { if (mFilter == null) { mFilter = new SimpleFilter(); } return mFilter; } public int getCount() { return unfilteredValues.size(); } private class SimpleFilter extends Filter { @SuppressWarnings("unchecked") @Override protected FilterResults performFiltering(CharSequence prefix) { FilterResults results = new FilterResults(); String prefixString = null == prefix ? null : prefix.toString().toLowerCase(); ArrayList&lt;HashMap&lt;String, String&gt;&gt; unfilteredValues; if (null != prefixString &amp;&amp; prefixString.length() &gt; 0) { synchronized (mData) { unfilteredValues = (ArrayList&lt;HashMap&lt;String, String&gt;&gt;) mData.clone(); } for (int i = unfilteredValues.size() - 1; i &gt;= 0; --i) { HashMap&lt;String, String&gt; h = unfilteredValues.get(i); String str = (String)h.get(from[0]).toString(); if (!str.toLowerCase().startsWith(prefixString)) { unfilteredValues.remove(i); } } //Log.i(Constants.TAG, String.valueOf(unfilteredValues.size())); results.values = unfilteredValues; results.count = unfilteredValues.size(); } else { synchronized (mData) { results.values = mData; results.count = mData.size(); } } return results; } @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { //noinspection unchecked unfilteredValues = (ArrayList&lt;HashMap&lt;String, String&gt;&gt;) results.values; notifyDataSetChanged(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload