Search Results

Search found 1459 results on 59 pages for 'arraylist'.

Page 8/59 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How put <Spanned> into list.setAdapter?

    - by svebee
    Simple but little tricky, if I have list.setAdapter(new ArrayAdapter<String>(this,R.layout.double_row, R.id.doubleRow, articleItemsHelper)); it works if articleItemsHelper is String, but I wanna have HTML formatting in there so when articleItemsHelper is type Spanned this (adapter) doesn't work. ArrayList<Spanned> articleItemsHelper = new ArrayList<Spanned>(); What's the solution?

    Read the article

  • spring-mvc binding arraylist in form

    - by Mike
    In my controller I added an ArrayList to my model with the attribute name "users". Now I looked around and this is the method I found (including a question here): <form:form action="../user/edit" method="post" modelAttribute="users"> <table> <c:forEach var="user" items="${users}" varStatus="counter"> <tr> <td> <form:input path="users[${counter.index}].age"/> </td> <td><button type="submit" name="updateId" id="Update" value="${user.id}">Update</button></td> </tr> </c:forEach> </table> </form:form> But when I load the JSP page I get: .springframework.beans.NotReadablePropertyException: Invalid property 'projects[0]' of bean class [java.util.ArrayList]: Bean property 'users[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? So apparantely this isn't the way to go, but in that case how do I bind an arraylist so I can edit the values?

    Read the article

  • Help matching fields between two classes

    - by Michael
    I'm not too experienced with Java yet, and I'm hoping someone can steer me in the right direction because right now I feel like I'm just beating my head against a wall... The first class is called MeasuredParams, and it's got 40+ numeric fields (height, weight, waistSize, wristSize - some int, but mostly double). The second class is a statistical classifier called Classifier. It's been trained on a subset of the MeasuredParams fields. The names of the fields that the Classifier has been trained on is stored, in order, in an array called reqdFields. What I need to do is load a new array, toClassify, with the values stored in the fields from MeasuredParams that match the field list (including order) found in reqdFields. I can make any changes necessary to the MeasuredParams class, but I'm stuck with Classifier as it is. My brute-force approach was to get rid of the fields in MeasuredParams and use an arrayList instead, and store the field names in an Enum object to act as an index pointer. Then loop through the reqdFields list, one element at a time, and find the matching name in the Enum object to find the correct position in the arrayList. Load the value stored at that positon into toClassify, and then continue on to the next element in reqdFields. I'm not sure how exactly I would search through the Enum object - it would be a lot easier if the field names were stored in a second arrayList. But then the index positions between the two would have to stay matched, and I'm back to using an Enum. I think. I've been running around in circles all afternoon, and I keep thinking there must be an easier way of doing it. I'm just stuck right now and can't see past what I've started. Any help would be GREATLY appreciated. Thanks so much! Michael

    Read the article

  • Java Bucket Sort on Strings

    - by Michael
    I can't figure out what would be the best way to use Bucket Sort to sort a list of strings that will always be the same length. An algorithm would look like this: For the last character position down to the first: For each word in the list: Place the word into the appropriate bucket by current character For each of the 26 buckets(arraylists) Copy every word back to the list I'm writing in java and I'm using an arraylist for the main list that stores the unsorted strings. The strings will be five characters long each. This is what I started. It just abrubdly stops within the second for loop because I don't know what to do next or if I did the first part right. ArrayList<String> count = new ArrayList<String>(26); for (int i = wordlen; i > 0; i--) { for (int j = 0; i < myList.size(); i++) myList.get(j).charAt(i) } Thanks in advanced.

    Read the article

  • ArrayList<String> NullPointerException

    - by Carlucho
    Am trying to solve a labyrinth by DFS, using adj List to represent the vertices and edges of the graph. In total there are 12 nodes (3 rows[A,B,C] * 4 cols[0,..,3]). My program starts by saving all the vertex labels (A0,..C3), so far so good, then checks the adjacent nodes, also no problems, if movement is possible, it proceeds to create the edge, here its where al goes wrong. adjList[i].add(vList[j].label); I used the debugger and found that vList[j].label is not null it contains a correct string (ie. "B1"). The only variables which show null are in adjList[i], which leads me to believe i have implemented it wrongly. this is how i did it. public class GraphList { private ArrayList<String>[] adjList; ... public GraphList(int vertexcount) { adjList = (ArrayList<String>[]) new ArrayList[vertexCount]; ... } ... public void addEdge(int i, int j) { adjList[i].add(vList[j].label); //NULLPOINTEREXCEPTION HERE } ... } I will really appreaciate if anyone can point me on the right track regrading to what its going wrong... Thanks!

    Read the article

  • ArrayList<Int> Collections.Sort and LineNumberReader Help How to

    - by user1819551
    I have a issue i can't get it to work now let going to the point a explain in the code thanks. This is my class: what I want to do is insert the Integers sort the list and buffer writer in a column with out coma. Now I getting this: [1110018, 1110032, 1110056, 1110059, 1110063, 1110085, 1110096, 1110123, 1110125, 1110185, 1110456, 1110459] I want like this: 111xxxxx 111xxxx xxxx....... I can't do it in single array, have to be in ArrayList. This is my collecting: list.addNumbers(numbers); list.display(); This is my writer: Is buffered coma.write("\n"+list.display()); coma.flush();<br/> Here is my class: public class IdCount {<br/> private ArrayList<Integer> properNumber = new ArrayList<>(); public void addNumbers(Integer numbers) { properNumber.add(numbers); Collections.sort(properNumber); } public String display() { //(I try .toString() Not work) return properNumber.toString(); } My second issue is LineNumberReader: This is my collecting and my writing: try { Reader input = new BufferedReader( new FileReader(inputFile)); try (Scanner in = new Scanner(input)) { while (in.hasNext()) { //(More Code) asp = new LineNumberReader(input); int rom = 0; while (asp.readLine()!=null){ rom++; } System.out.println(rom); coma.write(rom); This one will not write anything an my System Print give me only 12 0 in column.

    Read the article

  • update attribute a element in arraylist on java ?

    - by tiendv
    I have a class Class TextChunks extends Token { ArrayList<Token> arrt = new ArrayList<Token>(); } extent fron class : class Token { String s; int frequency = 1 ;// Tern frequency in TextChunk } Now in token i have arraylist token , i want to update attribute frequency of token in Texchunks when have more than one tokens same . For clearly a give a example : Texchunks :" in particular in domain and range in some " So have 8 token : in,particular,in,domain,and,range,in,some i want update attribute frequency for token : in this example when i get attribute frequency of token "in" must return 3 it mean when i call : get frequency of Texchunks when dislay : in 3 particular 1 in 3 domain 1 and 1 range 1 in 3 some 1 here my code : public TextChunks updateFrequencyOfTokenInTextChunks (TextChunks tc) throws CloneNotSupportedException { TextChunks result = (TextChunks) tc.clone(); for (int i =0 ; i< result.arrt.size() ; i++ ){ int j=i+1; if (result.arrt.get(i).compareTwoToken(result.arrt.get(j))== true ) { // help here how to update attribute result.arrt.get(i) // and result.arrt.get(J) = ++ and } } return tc; } Thanks in advandce

    Read the article

  • Struts2 Populating Checkbox from Arraylist of Objects

    - by user2972139
    I'm sure that I'm doing something dumb but I've been going craze over the last couple of days trying to get my checkboxes filled out inside an iterator that goes over an arraylist of object. Here is my object: public class EmailObject { int emailId; String emailAddress; public int getEmailId() { return emailId; } public void setEmailId(int emailId) { this.emailId = emailId; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } } In my action class, I create an arraylist of the above EmailObjects. On my jsp page, I can get checkboxes through a checkboxlist (but this isn't good for me because I want it to be vertical and don't want to mess with the struts styles) <s:checkboxlist name="selectedEmails" list="userEmails" listValue="emailAddress" listKey="emailId" /> I can also iterate over the arraylist userEmails and display the values: <s:iterator value="userEmails" var="thisEmailData"> <s:property value="emailId"/> <s:property value="emailAddress"/> </s:iterator> But I can't get it to display the emailId when iterating over the arraylist userEmails. I tried all of these: <s:iterator value="userEmails" var="thisEmailData"> <tr><td><s:property value="emailId"/></td></tr> <tr><td> <s:checkbox fieldValue="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox fieldValue="emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#thisEmailData.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="#userEmails.emailId" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#thisEmailData.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="%{#userEmails.emailId}" name="emailAddressesCB" theme="simple" ></s:checkbox> <s:checkbox value="emailId" name="emailAddressesCB" theme="simple" > </s:checkbox> <s:property value="emailAddress"/> </td></tr> </s:iterator> </td></tr> </s:iterator> From the above, the value field is never filled with the value of the emailId. I know I'm missing something basic. What is it? THANK YOU.

    Read the article

  • Question about casting a class in Java with generics

    - by Florian F
    In Java 6 Class<? extends ArrayList<?>> a = ArrayList.class; gives and error, but Class<? extends ArrayList<?>> b = (Class<? extends ArrayList<?>>)ArrayList.class; gives a warning. Why is (a) an error? What is it, that Java needs to do in the assignment, if not the cast shown in (b)? And why isn't ArrayList compatible with ArrayList? I know one is "raw" and the other is "generic", but what is it you can do with an ArrayList and not with an ArrayList, or the other way around?

    Read the article

  • JQuery UI Autocomplete TextBox in ASP.NET C# with ArrayList

    - by Avishek Kumar
    hello, I am a asp.net coder looking forward to the "easiest tutorial on the planet" to understand how to make a JQuery Autocomplete in ASP.NET c# with ArrayList which not just me but every .net idiot can understand for once and forever as im tired of looking up so many tutorials which teach me nothing. Im referring to this http://jqueryui.com/demos/autocomplete/ library for autocomplete thing. Here is what exactly i want: 1ASP.NET text-box which has autocomplete added to it. 2It will fetch records from "search.aspx?q=searchtext" and get back maximum of 5 matching results in C# ArrayList Format 3Show those 5 matching autocomplete records below text-box as it does in the jquery UI demo page 4Keep doing the autocomplete work for every new Textvalue/changed value in Text-box Here is "what i don't want to see" in my help example: 1JSON, 2XML 3.ASMX, LINQ, Theories of Book and all weired stuff So let me see who actually knows the best code for helping me. I would be thankful to the best ASP.NET coder who helps me out.

    Read the article

  • LinkedHashMap vs HashMap != LinkedList vs ArrayList

    - by Markos Fragkakis
    I have read that LinkedHashMap has faster iteration speed than HashMap because its elements are doubly linked to each other. Additionally, because of this, LinkedHashMap is slower when inserting or deleting elements. Presumably because these links also need to be updated. Although I can see an analogy to LinkedList vs ArrayList, in that the elements of LinkedList are also doubly-linked, I read that it iterates slower than ArrayList, and has faster insertion and deletion times. Why is this? Perhaps I am making a mistake somewhere? Cheers1

    Read the article

  • BlazeDS - Conversion from ArrayList <BaseClass> on java side to Actionscript

    - by user294280
    Hi, So we have a java class with two ArrayLists of generics. It looks like public class Blah { public ArrayList<ConcreteClass> a; public ArrayList<BaseClass> b; } by using [ArrayElementType('ConcreteClass')] in the actionscript class, we are able to get all the "a"s converted fine. However with "b", since the actual class coming across the line is a heterogeneous mix of classes like BaseClassImplementation1, BaseClassImplementation2 etc, it gets typed as an object. Is there a way to convert it to the specific concrete class assuming that a strongly typed AS version of the java class exists on the client side thanks for your help! Regis

    Read the article

  • Sort ArrayList of custom Objects by property

    - by Samuel
    Hello World!! :D I had a question which is pretty easy if you know the answer I guess. I read about sorting ArrayLists using a Comparator but somehow in all of the examples people used compareTo which according to some research is a method working on Strings... I wanted to sort an ArrayList of custom objects by one of their properties: a Date object (getStartDay()). Normally I compare them by item1.getStartDate().before(item2.getStartDate()) so I was wondering whether I could write something like: public class customComparator { public boolean compare(Object object1, Object object2) { return object1.getStartDate().before(object2.getStartDate()); } } public class randomName { ... Collections.sort(Database.arrayList, new customComparator); ... } I just started with Java so please forgive my ignorance :) Thanks in advance!! -Samuel

    Read the article

  • Deleting from arraylist and exporting back to .buab file(Java)

    - by Dave
    Ive made an address book. I can currently write to the arraylist and save it back to the .buab file, but I cant delete from the arraylist and export it back to the .buab file? Im pretty much stuck on this. Im able to retrive contacts from the .buab and scroll through them using the JTextFields and buttons ive created. Any help will be dearly appreciated. Ive set up seprate classes for all operations (newcontacts, nextcontact etc). If you need the code posted let me know.. Cheers Dave

    Read the article

  • Error when starting an activity

    - by Adam
    I'm starting an activity when a button is pressed, and normally (in other apps) haven't had an issue. But when I press the button in this app, I get an "unable to marshal value" error. Exact(ish) error from LogCat: 03-22 02:49:02.883: WARN/System.err(252): java.lang.RuntimeException: Parcel: unable to marshal value {CLASSNAME}@44dcf1b8 I feel that this might be related to the extra that I'm passing to the intent. I'm passing an ArrayList as a serializable to this new intent. My concern is that the data structure that the ArrayList contains isn't being serialized (as it's a personal data structure). Is the array list content data structure causing this? Something else that I'm missing?

    Read the article

  • Forcing GWT to assume List is implemented as ArrayList

    - by joecks
    For some reason I'm stucked with model classes using List as Collection Type and I would like to use the model on the client side. However GWT of course fails serializing java.util.List. However all implementations of List in this model are based on ArrayList. So is it possible to tell GWT to assume List is ArrayList? Edit GWT fails on compile time, since a possible candidate for List is also java.util.Collections.SingeltonList - which can not be compiled. I'm using GWT 2.1 and Java 1.6 .

    Read the article

  • Java - Thread safety of ArrayList constructors

    - by andy boot
    I am looking at this piece of code. This constructor delegates to the native method "System.arraycopy" Is it Thread safe? And by that I mean can it ever throw a ConcurrentModificationException? public Collection<Object> getConnections(Collection<Object> someCollection) { return new ArrayList<Object>(someCollection); } Does it make any difference if the collection being copied is ThreadSafe eg a CopyOnWriteArrayList? public Collection<Object> getConnections(CopyOnWriteArrayList<Object> someCollection) { return new ArrayList<Object>(someCollection); }

    Read the article

  • multi-dimensional ArrayList

    - by wishi
    Hi! Just a very small question... I seem to run into too much complexity here: I have to realize an index-structure like {42, someString}. I tried: Object entry[][] = new Object[1][1]; ArrayList<Object> my_list = new ArrayList<Object>(); However that looks really strange. Isn't there a better much simpler solution to just store some Integer and a String? I need to perfrom search for the Strings and return the Integer... so I thought Collections and ArrayLists are good friends in the Java API.

    Read the article

  • How to find the largest square in the number (Java)

    - by Ypsilon IV
    Hello everyone, I want to find the largest square in the number, but I am stuck at some point. I would really appreciate some suggestions. This is what I've done so far: I take the number on the input, factorize into prime numbers, and put the sequence of prime numbers to ArrayList. Numbers are sorted, in a sense, thus the numbers in the sequence are increasing. For example, 996 is 2 2 3 83 1000 is 2 2 2 5 5 5 100000 is 2 2 2 2 2 5 5 5 5 5 My idea now is to count number of occurrences of each elements in the sequence, so if the number of occurrences is divisible by two, then this is the square. In this way, I can get another sequence, where the right most element divisible by two is the largest square. What is the most efficient way to count occurrences in the ArrayList? Or is there any better way to find the largest square? Many thanks in advance!

    Read the article

  • Remove successive 0th entries in args[] for a Java command line interface?

    - by Bill IV
    I recall seeing, somewhere, an example that stepped through String args[] by deleting the lowest numbered value(s) public static void main( String args[]) { while (args.length > 0 ) { // do something and obliterate elements from args[] } } Obviously, a variable tracking current position in args and compared to args.length will do it; or an ArrayList made from args[]'s contents, with argsAL.size(). Am I mis-remembering an ArrayList example? I know this is a borderline question, the likely answer is, "No, there isn't and there shouldn't be either!". Maybe I'm over-focused... Bill

    Read the article

  • Write to text file using ArrayList

    - by Ugochukwutubelum Chiemenam
    The program is basically about reading from a text file, storing the current data into an ArrayList, then writing data (from user input) into the same text file. Kindly let me know where I am going wrong in this sub-part? The data inside the text file is as follows: abc t1 1900 xyz t2 1700 The compiler is showing an error at the line output.format("%s%s%s%n", public class justTesting { private Scanner input; private Formatter output; private ArrayList<Student> tk = new ArrayList<Student>(); public static void main(String[] args) { justTesting app = new justTesting(); app.create(); app.writeToFile(); } public void create() { Text entry = new Text(); Scanner input = new Scanner(System.in); System.out.printf("%s\n", "Please enter your name, ID, and year: "); while (input.hasNext()) { try { entry.setName(input.next()); entry.setTelNumber(input.next()); entry.setDOB(input.next()); for (int i = 0; i < tk.size(); i++) { output.format("%s%s%s%n", tk.get(i).getName(), tk.get(i) .getTelNumber(), tk.get(i).getDOB()); } } catch (FormatterClosedException fce) { System.err.println("Error writing to file."); return; } catch (NoSuchElementException nsee) { System.err.println("Invalid input. Try again: "); input.nextLine(); } System.out.printf("%s\n", "Please enter your name, ID, and year: "); } } public void writeToFile() { try { output = new Formatter("testing.txt"); } catch (SecurityException se) { System.err .println("You do not have write access permission to this file."); System.exit(1); } catch (FileNotFoundException fnfe) { System.err.println("Error opening or creating file."); System.exit(1); } } }

    Read the article

  • Array of an array (Database)

    - by Anne Mah Li'en
    I am trying to print out an array of an array from database Below are my codes. I am able to retrieve all the values from the first array. But error occurs when I am trying to retrieve the 2nd array from database. <% ArrayList<Questionnaire> allCategories =QuestionnaireController.getQuestionnaireByCategoryAll(); for(int i=0;i<allCategories.size();i++){ Questionnaire allCategoriesQuestionnaire=allCategories.get(i); out.println("<div class=\"silverheader\">" + "<a href= \"\">" + allCategoriesQuestionnaire.getCategory() + "</a>" + "</div>" + "<div class=\"submenu\">" + "ArrayList<Questionnaire> CategoriesSustainability =QuestionnaireController.getQuestionnaireByCategorySustainability();" + out.println(CategoriesSustainability.get(0).getCategory()); + "<br />" + "</div>"); } %>

    Read the article

  • When i add a bitmap to an array list the last element is duplicated in previous indexes

    - by saxofone2
    I'm trying to implement a personal way of undo/redo in a finger paint-like app. I have in synthesis three objects: the Main class (named ScorePadActivity), the relative Main Layout (with buttons, menus, etc, as well as a View object where I create my drawings), and a third object named ArrayList where i'm writing the undo/redo code. The problem is, when I press the undo button nothing happens, but if I draw anything again "one-time" and press undo, the screen is updated. If I draw many times, to see any changes happen on screen I have to press the undo button the same number of times I have drawn. Seems like (as in title) when I add a bitmap to the array list the last element is duplicated in previous indexes, and for some strange reason, everytime I press the Undo Button, the system is ok for one time, but starts to duplicate until the next undo. The index increase is verified with a series of System.out.println inserted in code. Now when I draw something on screen, the array list is updated with the code inserted after the invocation of touchup(); method in motionEvent touch_up(); } this.arrayClass.incrementArray(mBitmap); mPath.rewind(); invalidate(); and in ArrayList activity; public void incrementArray(Bitmap mBitmap) { this._mBitmap=mBitmap; _size=undoArray.size(); undoArray.add(_size, _mBitmap); } (All Logs removed for clear reading) The undo button in ScorePadActivity calls the undo method in View activity: Button undobtn= (Button)findViewById(R.id.undo); undobtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mView.undo(); } }); in View activity: public void undo() { this.mBitmap= arrayClass.undo(); mCanvas = new Canvas(mBitmap); mPath.rewind(); invalidate(); } that calls the relative undo method in ArrayList activity: public Bitmap undo() { // TODO Auto-generated method stub _size=undoArray.size(); if (_size>1) { undoArray.remove(_size-1); _size=undoArray.size(); _mBitmap = ((Bitmap) undoArray.get(_size-1)).copy(Bitmap.Config.ARGB_8888,true); } return _mBitmap; } return mBitmap and invalidate: Due to my bad English I have made a scheme to make the problem more clear: I have tried with HashMap, with a simple array, I have tried to change mPath.rewind(); with reset();, new Path(); etc but nothing. Why? Sorry for the complex answer, i want give you a great thanks in advance. Best regards

    Read the article

  • Returning an array from an activity

    - by Boardy
    I am currently working on an android project and I want to be able to startActivityForResult so that I can return an array of. The array is an ArrayList<Spanned> lets say its called myArray. From what I've read I can't return an array directly from the activty using the set result so I was thinking that once the array has added all the data to the array, I can then call the toString function on it, i.e. myArray.toString(). If I do this, I have no idea how I can then convert this back into the original ArrayList<Spanned>. Thanks for any help you can provide.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >