Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Android RecyclerView Help.......
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="dushan135" data-source="post: 20111314" data-attributes="member: 313895"><p>mage app eke recyclerview ekata mama item add karanawa shopping cart ekaka wage. A row wala tinawa edit text ekak. ekata apita one value ekak type karanna tinne. mama a data server ekakata send karanawa. Prashne tinne mama item 10,12k add karala edit text eke value type karala send karaddi send wenne mul row 5 tina value tika witharai hariyata. 6 weni eke idala send wenne 5 weni edit text eke tibuna value eka.</p><p></p><p><strong>me tinne udaharanayak.</strong></p><p></p><p>Quantity : 1</p><p>Quantity : 2</p><p>Quantity : 3</p><p>Quantity : 4</p><p>Quantity : 5</p><p>Quantity : 5</p><p>Quantity : 5</p><p>Quantity : 5</p><p>Quantity : 5</p><p>Quantity : 5</p><p></p><p>danna kenek udawwak denna.</p><p></p><p><strong><span style="font-size: 12px">me tinne main class eke method eka</span></strong></p><p></p><p><span style="color: red">private class SendItemAsync extends AsyncTask<Void, Void, Void> {</span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> protected void onPreExecute() {</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> protected Void doInBackground(Void... arg0) {</span></p><p><span style="color: red"></span></p><p><span style="color: red"> //Create JSON string start</span></p><p><span style="color: red"> json_string = "{\"sending_items\":[";</span></p><p><span style="color: red"></span></p><p><span style="color: red"> for (int i = 0; i < myRecyclerViewAdapter.getItemCount(); i++) {</span></p><p><span style="color: red"></span></p><p><span style="color: red"> //Repeat and loop this until all objects are added (and add try+catch)</span></p><p><span style="color: red"> try {</span></p><p><span style="color: red"> JSONObject obj_new = new JSONObject();</span></p><p><span style="color: red"> obj_new.put("order_no", orderIdForItemTable);</span></p><p><span style="color: red"> obj_new.put("items", myRecyclerViewAdapter.getItemName(i).toString());</span></p><p><span style="color: red"> obj_new.put("items_no", myRecyclerViewAdapter.getItemPCode(i).toString());</span></p><p><span style="color: red"> obj_new.put("plant", myRecyclerViewAdapter.getItemPlant(i).toString());</span></p><p><span style="color: red"> obj_new.put("quantity", getNumPicNumber(i));</span></p><p><span style="color: red"> json_string = json_string + obj_new.toString() + ",";</span></p><p><span style="color: red"></span></p><p><span style="color: red"> } catch (JSONException e) {</span></p><p><span style="color: red"> e.printStackTrace();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> //Close JSON string</span></p><p><span style="color: red"> json_string = json_string.substring(0, json_string.length() - 1);</span></p><p><span style="color: red"> json_string += "]}";</span></p><p><span style="color: red"></span></p><p><span style="color: red"> HttpParams httpParams = new BasicHttpParams();</span></p><p><span style="color: red"> HttpConnectionParams.setConnectionTimeout(httpParams, 3500);</span></p><p><span style="color: red"> HttpConnectionParams.setSoTimeout(httpParams, 1000);</span></p><p><span style="color: red"> HttpClient client = new DefaultHttpClient(httpParams);</span></p><p><span style="color: red"></span></p><p><span style="color: red"> String url = AppConfig.URL_ITEMS_SEND;</span></p><p><span style="color: red"></span></p><p><span style="color: red"> HttpPost request = new HttpPost(url);</span></p><p><span style="color: red"> try {</span></p><p><span style="color: red"> request.setEntity(new ByteArrayEntity(json_string.getBytes("UTF8")));</span></p><p><span style="color: red"> } catch (UnsupportedEncodingException e) {</span></p><p><span style="color: red"> e.printStackTrace();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> request.setHeader("json", json_string);</span></p><p><span style="color: red"> request.setHeader("Accept", "application/json");</span></p><p><span style="color: red"> request.setHeader("Content-Type", "application/json");</span></p><p><span style="color: red"> Log.i("", "excuting request");</span></p><p><span style="color: red"> HttpResponse response = null;</span></p><p><span style="color: red"> try {</span></p><p><span style="color: red"> response = client.execute(request);</span></p><p><span style="color: red"> Log.d("HTTP Response", response.getStatusLine().toString());</span></p><p><span style="color: red"> try {</span></p><p><span style="color: red"> String responseBody = EntityUtils.toString(response.getEntity());</span></p><p><span style="color: red"> Log.d("Server Response", responseBody);</span></p><p><span style="color: red"> } catch (IOException e) {</span></p><p><span style="color: red"> e.printStackTrace();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> } catch (IOException e) {</span></p><p><span style="color: red"> e.printStackTrace();</span></p><p><span style="color: red"></span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> return null;</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> protected void onPostExecute(Void aVoid) {</span></p><p><span style="color: red"> finish();</span></p><p><span style="color: red"> Bundle basket = new Bundle();</span></p><p><span style="color: red"> basket.putString("dealerName", dealerName);</span></p><p><span style="color: red"> basket.putString("orderNo", newOrderId);</span></p><p><span style="color: red"> basket.putString("jsonString", json_string);</span></p><p><span style="color: red"> Intent intent = new Intent(SelectItem.this, ItemCart.class);</span></p><p><span style="color: red"> intent.putExtras(basket);</span></p><p><span style="color: red"> startActivity(intent);</span></p><p><span style="color: red"> finish();</span></p><p><span style="color: red"> //Toast.makeText(getApplicationContext(), json_string, Toast.LENGTH_LONG).show();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> private String getNumPicNumber(int i) {</span></p><p><span style="color: red"> if (myRecyclerView.findViewHolderForLayoutPosition(i) instanceof SelectItemAdapter.ItemHolder) {</span></p><p><span style="color: red"> SelectItemAdapter.ItemHolder childHolder = (SelectItemAdapter.ItemHolder) myRecyclerView.findViewHolderForLayoutPosition(i);</span></p><p><span style="color: red"> numberPickerNumber = childHolder.getQtyNumber();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> return numberPickerNumber;</span></p><p><span style="color: red"> }</span></p><p></p><p></p><p><strong><span style="font-size: 12px">me tinne adapter class eka</span></strong></p><p></p><p><span style="color: red">public class SelectItemAdapter extends RecyclerView.Adapter<SelectItemAdapter.ItemHolder> {</span></p><p><span style="color: red"></span></p><p><span style="color: red"> private List<String> itemsName, itemsQty, itemsPCode, itemPlant;</span></p><p><span style="color: red"> private OnItemClickListener onItemClickListener;</span></p><p><span style="color: red"> private LayoutInflater layoutInflater;</span></p><p><span style="color: red"> private RecyclerView myRecyclerview;</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public SelectItemAdapter(Context context) {</span></p><p><span style="color: red"> layoutInflater = LayoutInflater.from(context);</span></p><p><span style="color: red"> itemsName = new ArrayList<String>();</span></p><p><span style="color: red"> itemsQty = new ArrayList<String>();</span></p><p><span style="color: red"> itemsPCode = new ArrayList<String>();</span></p><p><span style="color: red"> itemPlant = new ArrayList<String>();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> public SelectItemAdapter.ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {</span></p><p><span style="color: red"> View itemView = layoutInflater.inflate(R.layout.custom_row_selected_item, parent, false);</span></p><p><span style="color: red"> return new ItemHolder(itemView, this);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> public void onBindViewHolder(SelectItemAdapter.ItemHolder holder, int position) {</span></p><p><span style="color: red"> holder.setItemName(itemsName.get(position));</span></p><p><span style="color: red"> holder.setItemQty(itemsQty.get(position));</span></p><p><span style="color: red"> holder.setItemPCode(itemsPCode.get(position));</span></p><p><span style="color: red"> holder.setItemPlant(itemPlant.get(position));</span></p><p><span style="color: red"></span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> public int getItemViewType(int position) {</span></p><p><span style="color: red"> return position;</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> public int getItemCount() {</span></p><p><span style="color: red"> return itemsName.size();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public Object getItemName(int position) {</span></p><p><span style="color: red"> return itemsName.get(position);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public Object getItemPCode(int position) {</span></p><p><span style="color: red"> return itemsPCode.get(position);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public Object getItemPlant(int position) {</span></p><p><span style="color: red"> return itemPlant.get(position);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void setOnItemClickListener(OnItemClickListener listener) {</span></p><p><span style="color: red"> onItemClickListener = listener;</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public OnItemClickListener getOnItemClickListener() {</span></p><p><span style="color: red"> return onItemClickListener;</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"></span></p><p><span style="color: red"> public interface OnItemClickListener {</span></p><p><span style="color: red"> public void onItemClick(ItemHolder item, int position);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void add(int location, String iName, String iQty, String iPCode, String iPlant) {</span></p><p><span style="color: red"> itemsName.add(location, iName);</span></p><p><span style="color: red"> itemsQty.add(location, iQty);</span></p><p><span style="color: red"> itemsPCode.add(location, iPCode);</span></p><p><span style="color: red"> itemPlant.add(location, iPlant);</span></p><p><span style="color: red"> notifyItemInserted(location);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void remove(int location) {</span></p><p><span style="color: red"> if (location >= itemsName.size())</span></p><p><span style="color: red"> return;</span></p><p><span style="color: red"></span></p><p><span style="color: red"> itemsName.remove(location);</span></p><p><span style="color: red"> notifyItemRemoved(location);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public static class ItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {</span></p><p><span style="color: red"></span></p><p><span style="color: red"> private SelectItemAdapter parent;</span></p><p><span style="color: red"> TextView textItemName, txtPCode, txtAvailableQty, txtTempQty, txtPlant;</span></p><p><span style="color: red"> Button bRemove;</span></p><p><span style="color: red"> EditText numPicker;</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public ItemHolder(View itemView, SelectItemAdapter parent) {</span></p><p><span style="color: red"> super(itemView);</span></p><p><span style="color: red"> this.parent = parent;</span></p><p><span style="color: red"> textItemName = (TextView) itemView.findViewById(R.id.txtProductName);</span></p><p><span style="color: red"> txtAvailableQty = (TextView) itemView.findViewById(R.id.txtAvailbleQty);</span></p><p><span style="color: red"> txtPCode = (TextView) itemView.findViewById(R.id.txtPCode);</span></p><p><span style="color: red"> txtPlant = (TextView) itemView.findViewById(R.id.txtPlant);</span></p><p><span style="color: red"> bRemove = (Button) itemView.findViewById(R.id.bRemove);</span></p><p><span style="color: red"> numPicker = (EditText) itemView.findViewById(R.id.numberPicker);</span></p><p><span style="color: red"></span></p><p><span style="color: red"> bRemove.setOnClickListener(this);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void setItemName(CharSequence name) {</span></p><p><span style="color: red"> textItemName.setText(name);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void setItemQty(CharSequence name) {</span></p><p><span style="color: red"> txtAvailableQty.setText(name);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void setItemPCode(CharSequence name) {</span></p><p><span style="color: red"> txtPCode.setText(name);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public void setItemPlant(CharSequence name) {</span></p><p><span style="color: red"> txtPlant.setText(name);</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public String getQtyNumber() {</span></p><p><span style="color: red"> return numPicker.getText().toString();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> public CharSequence getItemName() {</span></p><p><span style="color: red"> return textItemName.getText();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"></span></p><p><span style="color: red"> public CharSequence getItemPCode() {</span></p><p><span style="color: red"> return txtPCode.getText();</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red"> @Override</span></p><p><span style="color: red"> public void onClick(View v) {</span></p><p><span style="color: red"> final OnItemClickListener listener = parent.getOnItemClickListener();</span></p><p><span style="color: red"> if (listener != null) {</span></p><p><span style="color: red"> listener.onItemClick(this, getPosition());</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"> }</span></p><p><span style="color: red"></span></p><p><span style="color: red">}</span></p></blockquote><p></p>
[QUOTE="dushan135, post: 20111314, member: 313895"] mage app eke recyclerview ekata mama item add karanawa shopping cart ekaka wage. A row wala tinawa edit text ekak. ekata apita one value ekak type karanna tinne. mama a data server ekakata send karanawa. Prashne tinne mama item 10,12k add karala edit text eke value type karala send karaddi send wenne mul row 5 tina value tika witharai hariyata. 6 weni eke idala send wenne 5 weni edit text eke tibuna value eka. [B]me tinne udaharanayak.[/B] Quantity : 1 Quantity : 2 Quantity : 3 Quantity : 4 Quantity : 5 Quantity : 5 Quantity : 5 Quantity : 5 Quantity : 5 Quantity : 5 danna kenek udawwak denna. [B][SIZE="3"]me tinne main class eke method eka[/SIZE][/B] [COLOR="red"]private class SendItemAsync extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { } @Override protected Void doInBackground(Void... arg0) { //Create JSON string start json_string = "{\"sending_items\":["; for (int i = 0; i < myRecyclerViewAdapter.getItemCount(); i++) { //Repeat and loop this until all objects are added (and add try+catch) try { JSONObject obj_new = new JSONObject(); obj_new.put("order_no", orderIdForItemTable); obj_new.put("items", myRecyclerViewAdapter.getItemName(i).toString()); obj_new.put("items_no", myRecyclerViewAdapter.getItemPCode(i).toString()); obj_new.put("plant", myRecyclerViewAdapter.getItemPlant(i).toString()); obj_new.put("quantity", getNumPicNumber(i)); json_string = json_string + obj_new.toString() + ","; } catch (JSONException e) { e.printStackTrace(); } } //Close JSON string json_string = json_string.substring(0, json_string.length() - 1); json_string += "]}"; HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 3500); HttpConnectionParams.setSoTimeout(httpParams, 1000); HttpClient client = new DefaultHttpClient(httpParams); String url = AppConfig.URL_ITEMS_SEND; HttpPost request = new HttpPost(url); try { request.setEntity(new ByteArrayEntity(json_string.getBytes("UTF8"))); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } request.setHeader("json", json_string); request.setHeader("Accept", "application/json"); request.setHeader("Content-Type", "application/json"); Log.i("", "excuting request"); HttpResponse response = null; try { response = client.execute(request); Log.d("HTTP Response", response.getStatusLine().toString()); try { String responseBody = EntityUtils.toString(response.getEntity()); Log.d("Server Response", responseBody); } catch (IOException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { finish(); Bundle basket = new Bundle(); basket.putString("dealerName", dealerName); basket.putString("orderNo", newOrderId); basket.putString("jsonString", json_string); Intent intent = new Intent(SelectItem.this, ItemCart.class); intent.putExtras(basket); startActivity(intent); finish(); //Toast.makeText(getApplicationContext(), json_string, Toast.LENGTH_LONG).show(); } } private String getNumPicNumber(int i) { if (myRecyclerView.findViewHolderForLayoutPosition(i) instanceof SelectItemAdapter.ItemHolder) { SelectItemAdapter.ItemHolder childHolder = (SelectItemAdapter.ItemHolder) myRecyclerView.findViewHolderForLayoutPosition(i); numberPickerNumber = childHolder.getQtyNumber(); } return numberPickerNumber; }[/COLOR] [B][SIZE="3"]me tinne adapter class eka[/SIZE][/B] [COLOR="red"]public class SelectItemAdapter extends RecyclerView.Adapter<SelectItemAdapter.ItemHolder> { private List<String> itemsName, itemsQty, itemsPCode, itemPlant; private OnItemClickListener onItemClickListener; private LayoutInflater layoutInflater; private RecyclerView myRecyclerview; public SelectItemAdapter(Context context) { layoutInflater = LayoutInflater.from(context); itemsName = new ArrayList<String>(); itemsQty = new ArrayList<String>(); itemsPCode = new ArrayList<String>(); itemPlant = new ArrayList<String>(); } @Override public SelectItemAdapter.ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = layoutInflater.inflate(R.layout.custom_row_selected_item, parent, false); return new ItemHolder(itemView, this); } @Override public void onBindViewHolder(SelectItemAdapter.ItemHolder holder, int position) { holder.setItemName(itemsName.get(position)); holder.setItemQty(itemsQty.get(position)); holder.setItemPCode(itemsPCode.get(position)); holder.setItemPlant(itemPlant.get(position)); } @Override public int getItemViewType(int position) { return position; } @Override public int getItemCount() { return itemsName.size(); } public Object getItemName(int position) { return itemsName.get(position); } public Object getItemPCode(int position) { return itemsPCode.get(position); } public Object getItemPlant(int position) { return itemPlant.get(position); } public void setOnItemClickListener(OnItemClickListener listener) { onItemClickListener = listener; } public OnItemClickListener getOnItemClickListener() { return onItemClickListener; } public interface OnItemClickListener { public void onItemClick(ItemHolder item, int position); } public void add(int location, String iName, String iQty, String iPCode, String iPlant) { itemsName.add(location, iName); itemsQty.add(location, iQty); itemsPCode.add(location, iPCode); itemPlant.add(location, iPlant); notifyItemInserted(location); } public void remove(int location) { if (location >= itemsName.size()) return; itemsName.remove(location); notifyItemRemoved(location); } public static class ItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener { private SelectItemAdapter parent; TextView textItemName, txtPCode, txtAvailableQty, txtTempQty, txtPlant; Button bRemove; EditText numPicker; public ItemHolder(View itemView, SelectItemAdapter parent) { super(itemView); this.parent = parent; textItemName = (TextView) itemView.findViewById(R.id.txtProductName); txtAvailableQty = (TextView) itemView.findViewById(R.id.txtAvailbleQty); txtPCode = (TextView) itemView.findViewById(R.id.txtPCode); txtPlant = (TextView) itemView.findViewById(R.id.txtPlant); bRemove = (Button) itemView.findViewById(R.id.bRemove); numPicker = (EditText) itemView.findViewById(R.id.numberPicker); bRemove.setOnClickListener(this); } public void setItemName(CharSequence name) { textItemName.setText(name); } public void setItemQty(CharSequence name) { txtAvailableQty.setText(name); } public void setItemPCode(CharSequence name) { txtPCode.setText(name); } public void setItemPlant(CharSequence name) { txtPlant.setText(name); } public String getQtyNumber() { return numPicker.getText().toString(); } public CharSequence getItemName() { return textItemName.getText(); } public CharSequence getItemPCode() { return txtPCode.getText(); } @Override public void onClick(View v) { final OnItemClickListener listener = parent.getOnItemClickListener(); if (listener != null) { listener.onItemClick(this, getPosition()); } } } }[/COLOR] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom