arraylist

How to properly add data to ArrayList - Android

≯℡__Kan透↙ 提交于 2020-01-06 14:46:08
问题 I have a class the extends arrayAdapter. I am trying to add variables to the list but I am not sure exactly how to do so. Here is my current ArrayAdapter class. class Item { String username; String number; String content; } class ListAdapter extends ArrayAdapter<Item> { public ListAdapter(Context context, int textViewResourceId) { super(context, textViewResourceId); // TODO Auto-generated constructor stub } private List<Item> items; public ListAdapter(Context context, int resource, List<Item>

How to modify add of ArrayList

社会主义新天地 提交于 2020-01-06 14:44:12
问题 I'm trying to modify an "add" method such that it checks if a BinItem's SKU are the same. If it's unique, I will add it. If it has similar SKU as others, it will remove the BinItem, create a new one (of the same SKU) but sum up the Quantities. I tried my best but couldn't get my head around it... here's my effort. I tried making a nested for loop so it goes through each one, check if they're the same and delete if they are. It ended up deleting everything. public class Bin { private String

which item was clicked in a clickable list view

99封情书 提交于 2020-01-06 12:36:30
问题 i have a listView which is filled with an arraylist of strings and i want to make it clickable .. but i cant recognize which item was clicked i've made this but it doesn't work ! is there way to know the string clicked ? if not is there a way to know even the position of clicked item? public class SearchResults extends Activity{ public ArrayList<String> findMovieByName(String name) { ArrayList<movie> matches = new ArrayList<movie>(); // go through list of members and compare name with given

which item was clicked in a clickable list view

孤街醉人 提交于 2020-01-06 12:36:03
问题 i have a listView which is filled with an arraylist of strings and i want to make it clickable .. but i cant recognize which item was clicked i've made this but it doesn't work ! is there way to know the string clicked ? if not is there a way to know even the position of clicked item? public class SearchResults extends Activity{ public ArrayList<String> findMovieByName(String name) { ArrayList<movie> matches = new ArrayList<movie>(); // go through list of members and compare name with given

Issue with passing a Custom ArrayList through Intent with Serialize

一世执手 提交于 2020-01-06 10:04:14
问题 I am attempting to pass an array List of Custom objects through from one class to the other. I used a wrapper class to pass over the array List: package perks; import java.io.Serializable; import java.util.ArrayList; public class PerkWrapper implements Serializable { private ArrayList<Perk> parliaments; public PerkWrapper(ArrayList<Perk> perks) { this.parliaments = perks; } public ArrayList<Perk> getParliaments() { return this.parliaments; } } I pass it like this: i.putExtra("perks", player

Android: Converting ArrayList to GSON runs out of memory

大憨熊 提交于 2020-01-06 08:26:29
问题 Hoping someone out there can explain this to me. I keep running out of memory when trying to store an ArrayList in my SharedPreferences . public void setCurrentAlarmList(ArrayList<CurrentAlarm> currentAlarms) { Log.e("SETTING LIST", "!!!"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor editor = prefs.edit(); Gson gson = new Gson(); String json = gson.toJson(currentAlarms); editor.putString(Constants.ALARM_LIST, json); editor.apply(

SwiftUI BIG list search

吃可爱长大的小学妹 提交于 2020-01-06 08:05:48
问题 Hello i'm try to search an airport in a big list of item create from an Array called airportVector of type AirportModel, but when I try to lunch the search as soon I type the first letter everything block! looks like the list is too big . if I leave only few item the list work. I tried to make my model conform to Equatable and Hashable but i'm not to expert how to use it.. look for some help or suggestion how to avoid the block. here my model import Foundation class AirportModel :

assign arraylist value to textview

北慕城南 提交于 2020-01-06 07:07:10
问题 I'm trying to set the value from my arraylist to the textview ArrayList<Integer> arrayListPage1, arrayListPage2, arrayListPage3, arrayListPage4, arrayListPage5; arrayListPage1 = new ArrayList<Integer>(rangeMode); arrayListPage2 = new ArrayList<Integer>(rangeMode); arrayListPage3 = new ArrayList<Integer>(rangeMode); arrayListPage4 = new ArrayList<Integer>(rangeMode); arrayListPage5 = new ArrayList<Integer>(rangeMode); totalCardInPage = new int[totalPage+1]; for(int j=1;j<=totalPage;j++){ int x

assign arraylist value to textview

与世无争的帅哥 提交于 2020-01-06 07:06:53
问题 I'm trying to set the value from my arraylist to the textview ArrayList<Integer> arrayListPage1, arrayListPage2, arrayListPage3, arrayListPage4, arrayListPage5; arrayListPage1 = new ArrayList<Integer>(rangeMode); arrayListPage2 = new ArrayList<Integer>(rangeMode); arrayListPage3 = new ArrayList<Integer>(rangeMode); arrayListPage4 = new ArrayList<Integer>(rangeMode); arrayListPage5 = new ArrayList<Integer>(rangeMode); totalCardInPage = new int[totalPage+1]; for(int j=1;j<=totalPage;j++){ int x

arraylist add to new recyclerview

故事扮演 提交于 2020-01-06 05:25:26
问题 Hi I am trying to add a new item to my chat, I use RXJava2, to make call to my REST API to get the chat data, with this nested json response. But I get an NullPointer when I try to add a new item to the Arraylist (Send new message): 09-08 13:35:14.529 2869-2869/com.jonathan.myapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.jonathan.myapp, PID: 2869 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.jonathan.myapp.models.ChatMessageUser.setUserId(java.lang