- Home /
I just wanna display my data in list view but i am not finding the solution, in unity how can we create list view..???
I am using web service for showing data through an API my data is loading properly and showing in console but i need listview to show it on GUI. Please help and thanks in advance
Answer by phort99 · Sep 03, 2013 at 08:15 AM
There is no API for creating an iOS style list view. If you need a real iOS list view, you could use a native plugin. If you just want to display some information in a list with Unity's GUI, GUILayout is your friend. Create a scroll view, and add labels or buttons or whatever you need.
Here's some sample code:
using UnityEngine;
using System.Collections;
public class listView : MonoBehaviour {
Vector2 scrollPosition = Vector2.zero;
void OnGUI () {
string[] listItems =
{
"Hello world,",
"this",
"is a",
"very",
"very",
"very",
"very",
"very",
"very",
"long",
"list.",
};
GUILayout.BeginArea(new Rect(0f, 0f, 300f, 200f), GUI.skin.window);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
GUILayout.BeginVertical(GUI.skin.box);
foreach (string item in listItems)
{
GUILayout.Label(item, GUI.skin.box, GUILayout.ExpandWidth(true));
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
GUILayout.EndArea();
}
}
@phort99: thanx for ur reply can u please explain with some example, actually i also tried GUILayout thing but not getting my solution.
Feel so fortunate, the fine answer here helped me a lot on solving the problem with listview control I am facing with. Since I am quite new in Unity and know nothing about listview, I read through a listview control tutorial but still got no idea. This question and its answer did me a great favor. But, still can't be clear with the native plug-in thing.
Answer by ShargonXL · Nov 03, 2014 at 11:14 AM
its possible to generate this items dynamic... to make something like this:
http://pic002.cnblogs.com/images/2011/31770/2011060717220256.png
https://lh4.ggpht.com/bjwAAE72H5znXX8L3MgOGKMyOCVjc7DgyRQGPqLqSKrkbiAowtWKy98EbwgHefiW1wQ=h900
the items row Heiht, its different to header row....
Sorry for my english :(
Answer by GrantTheAnt · Nov 27, 2014 at 11:28 PM
Our product, "ListView for Unity UI", is a ListView control that uses the same code interface as the .NET control. Check it out here! http://u3d.as/content/endgame-studios/list-view-for-unity-ui/998
Your answer
![](https://koobas.hobune.stream/wayback/20220613113459im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Running a Unity 4.6 game on Unity 4.5.2 - Possible? 1 Answer
Error ambiguous reference with Json 1 Answer
I want to add progress bar in my application, can anyone explain with one example. 0 Answers
Game Crashes on iphone3gs and iPod touch but work fine on iPhone 4s 1 Answer