Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get value of the editText in the adapter in android
    primarykey
    data
    text
    <p>I populated my <code>ListView</code> using the data from the database that was put in the hasmap. Each line(hashmap) in the <code>ListView</code> has <code>EditText</code>. My problem is I don't know how to get the value of the <code>EditText</code> in the hasmap. <img src="https://i.stack.imgur.com/M8Kuv.png" alt="enter image description here"></p> <p>Here is the code for that:</p> <pre><code>selectedFileNames = new String[listSelectedFileNames.size()]; for (int i = 0; i &lt; listSelectedFileNames.size(); i++) { selectedFileNames[i] = listSelectedFileNames.get(i); } selectedFileUri = new String[listSelectedFileUri.size()]; for (int i = 0; i &lt; listSelectedFileUri.size(); i++) { selectedFileUri[i] = listSelectedFileUri.get(i); } String myDate = tv_Date.getText().toString(); mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); for (int i = 0; i &lt; listSelectedFileNames.size(); i++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put(FILE_NAME, selectedFileNames[i]); map.put(DESC,""); map.put(UPLOADED_BY, "User"); map.put(DATE_UPLOADED, myDate); map.put(ACTION, "Delete"); map.put(ID, String.valueOf(i)); map.put(FILE_URI, selectedFileUri[i]); mylist.add(map); } 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); </code></pre> <p>Here is my xml for my adapter:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" &gt; &lt;LinearLayout android:id="@+id/listHeader1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical"&gt; &lt;TextView android:id="@+id/tv_iFile" android:layout_width="0dp" android:layout_height="wrap_content" android:textSize="13sp" android:textColor="@color/black" android:layout_weight="1" android:gravity="center" android:singleLine="true" android:paddingRight="3dp"/&gt; &lt;EditText android:id="@+id/txt_iDesc" android:layout_width="0dp" android:layout_height="22dp" android:layout_weight="1" android:textSize="13sp" android:textColor="@color/black" android:singleLine="true" android:paddingRight="3dp" android:gravity="center" android:background="@drawable/bg_ireporttxtbg" android:ems="10"/&gt; &lt;TextView android:id="@+id/tv_iUploadedBy" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:textSize="13sp" android:textColor="@color/black" android:gravity="center" android:singleLine="true"/&gt; &lt;TextView android:id="@+id/tv_iDateUploaded" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:textSize="13sp" android:gravity="center" android:clickable="true" android:textColor="@color/black"/&gt; &lt;TextView android:id="@+id/tv_iAction" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:textSize="13sp" android:textColor="@color/blue" android:gravity="center" android:clickable="true" android:text="Delete" android:singleLine="true"/&gt; &lt;TextView android:id="@+id/tv_iUri" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5" android:textSize="13sp" android:gravity="center" android:clickable="true" android:visibility="gone" android:text="Uri" /&gt; &lt;TextView android:id="@+id/tv_RowId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"/&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Please help or suggest any example for me to fix this.. Thanks!Below is the code for my custom adapter</p> <pre><code>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; 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]); 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); }); }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.
    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.
    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