How to set relationships between objects on Parse? - android

I have a parse object named Card and another called Category. I have 15 categories and gazillions of cards. I want to attach each card to one of the categories but in Parse when I try to set a relationship it redirects me to a screen where I actually have to create another category, but I just wanna choose from the existing ones.
What am I doing wrong?

Answer is simple, should just have used the Pointer type of relationship.

Related

Compare and merge two different generic List

I have in my code two generic list, One containing some plans and other containing promocode details, the size of these lists can be different, the only common elements available in both list can be two, lets say id and name.
So my question is, how can i compare these two lists and only retain plans containing same id or name and also retain the plans which are not present in the promo list, without writing my own code? if not, what is the best compare and merge method.
I have tried converting it to Collection and used retainAll
sample plan json:
{"id":14,"name":"60 Day","description":"60 Day","validity":60,"is_active":true,"price":7}
sample promoplan json:
{"id":6,"name":"120 Day","description":"120 Day","original_price":12.0,"new_price":0.0"}
EDIT ultimate goal (ie matching id's of both list are retained with new price in the plan list and also the non matching id's with the existing price on plan list)
Any kind of help or hints will be greatly appreciated.

how to use a list item to call and display a string in another fragment

i am a novice in android and i was trying to make an application that has two fragments, one with a listView with topics which when one is clicked it opens a topic description in the other fragment. i would like to know how to also store the large string for the description
If the data is dynamic you can store your topics and desciptions in a sqlite database. You have several possibilities:
You load the topic and description at the start and give over the description with a method or an interface to the second fragment.
You store the data in a database and give every entry a unique id and use a method or an interface to communicate with the second fragment and put the id to it. And then you use the id to get the description from database.
UPDATE #1
You can use arrays in your resource files. Create two arrays. One with your topics and the other with your descriptions. But the topics and descriptions have to be in the same order. For example the description of the second topic have to be on the second position in its array. Now you use the first array for your listview and the second(with the descriptions) in the description fragment. The "setOnItemClickListener" method of the listview have the position as a parameter. This is the same as the position of the topics and desciption in your arrays (when you dont resort anything).

Adding elements and saving that elements to array that is created in strings.xml

Suppose Type is the name of the array which contains A,B,C,D as elements and is created in strings.xml.Now in the form user can either select any of the elements or add new elements.Suppose user adds E,F,G .Now what i want to achieve is that anyhow the Type array have A,B,C,D,E,F,G in it. Using sqlite is done.But i want to save it in the Type array only and not anywhere else.Is it possible ?
Since anything that you define in res folder acquires a unique id in R.java, which is an array, and size of array cannot be changed at runtime.. So, it is not possible.
You can only save data to persistent storage like SQLite data base, shared preferences or a text file, each of which have different strengths and weaknesses and are suited for different situations, so take your pick.

Android: different objects in one list

I am a new to android developing. I am developing an android app for a shopping mall...
i want to have a screen where a list is displayed. Name of the mall and its photo should be displayed in the first section with its short one line address...
In the next sections the products should be displayed in the same way....
Product photo, Product Name and its price...
Please suggest me what topics should i read to create such a screen....
could fragments be used to create this screen???
Thanks in advance...
There are many ways. Like you can create a Customized List view for each screen. You can first create an Array List of objects of MallClassPojo. Like:
ArrayList<MallClassPojo> mallList.
Where your MallClassPojo contains the getter setter methods for Mall name,Mall image url or resourceID and short description of mall. Pass this mallList to your adapter class. Retrieve the details and show them in your customised List View. The next screen can be prepared in the same way also.
Well then you can create an Array List of JSON objects. In a JSON Object you can add different data like in one object you can add the company data and in another you can add product data. Isn't it?

ArrayList with Multiple data

I have a small issue with ArrayList. I have to fetch the document from the server.
The document contains 7 fields of data. I have to show the document names in the list view.
For this I have added different fields data to the different ArrayList. So when I click on the document name, based on the position of the document, I fetched the all fields data from the different Arraylist based on the position.
But Have a small issue using by using the above procedure. Is there any procedure that is not depend on the position, what I want is irrespective of position if I click on the Document,based on the keyword document data to be extract.
Any Help Appreciated.
Thanks in Advance.
I got your point. If you try to manage different ArrayLists then it would be difficult to manage it. I mean if you delete item from particular position from particular ArrayList then you will have to delete items from same position from other ArrayList, if you forgot to do so then it will be unbalanced.
Solution:
Instead feasible solution is to create ArrayList<Object> or ArrayList<HashMap<String,String>>, so your every item is the type of particular object, and every object contains detail and everything of particular items.
For example: ArrayList<Documents>, here ArrayList will contains list of Documents objects, and every objects contains values of 7 fields.
Its simply easy to define Documents class with getter/setter attributes.

Categories

Resources