void updateScrollView(DataTable dt) { foreach (DataRow dr in dt.Rows) { var item = GameObject.Instantiate(prefab) as RectTransform; item.SetParent(transform, false); listViewNode node = item.gameObject.GetComponent <listViewNode>(); node.setOwner(this); //詳細情報をノードに設定する photoDetailInfo info = new photoDetailInfo(); info.photoID = int.Parse(dr["id"].ToString()); node.setDetailInfo(info); listViewNodes.Add(node); //childImageName.sprite = Resources.Load<Sprite>("Icon"); //Debug.Log(dr["name"]); //お店の名前の取得 Text childTitleName = item.gameObject.transform.Find("titleText").gameObject.GetComponent <Text>(); childTitleName.text = dr["name"].ToString(); //jn["titlename"].Get<string>(); Image ratingStar = item.gameObject.transform.Find("ratingonImage").gameObject.GetComponent <Image>(); //評価の星を取得 string rate = dr["myrating"].ToString(); /* * if (float.Parse(rate) == 0) * { * rate = dr["rating"].ToString(); * } * */ ratingStar.fillAmount = float.Parse(rate) / 5.0f; //自分で評価した内容 myComment = item.gameObject.transform.Find("descriptionText ").gameObject.GetComponent <Text>(); string comment = dr["mycomment"].ToString(); if (comment != "") { myComment.text = comment; } //データベースから取得した情報を、各カラムに保存する。 //画像エリアの取得 Image childImageName = item.gameObject.transform.Find("Image").gameObject.GetComponent <Image>(); var imagePath = dr["image_path"]; if (imagePath != null) { Debug.Log(dr["image_path"].ToString()); CaptureView captureView = new CaptureView(); childImageName.sprite = captureView.GetSprite(dr["image_path"].ToString()); } } if (listViewNodes.Count != 0) { //scrollBar.SetActive(false); noDataText.SetActive(false); } //スクロールビューの頭から表示されるように scrollRect = scrollView.GetComponent <ScrollRect>(); scrollRect.verticalNormalizedPosition = 1; }
// Use this for initialization void Start() { shopName = GameObject.Find("shopName").GetComponent <Text>(); // データを条件指定して1件取得 DataRow drone = DataControl.getOneData("id=" + SceneUtility.photoid.ToString()); var imagePath = drone["image_path"]; if (imagePath != null) { CaptureView captureView = new CaptureView(); photoPicture.sprite = captureView.GetSprite(drone["image_path"].ToString()); } //店舗名の更新 var name = drone["name"]; if (name != null) { shopName.text = drone["name"].ToString(); } else { shopName.text = ""; } float myrating = 0; if (drone["myrating"] != null) { myrating = float.Parse(drone["myrating"].ToString()); } string rate = "0"; //rate = drone["rating"].ToString().ToString(); //Debug.Log(rate); //レビュー表記の更新 if (myrating != 0 && myrating > 0) { if (drone["myrating"] != null) { rate = drone["myrating"].ToString(); } } //星の画像を調整するための値を取得 float tempReviewNum = 0; if (rate != "0") { tempReviewNum = float.Parse(rate) / 5.0f; } //reviewStars.fillAmount = tempReviewNum; myReviewStars.fillAmount = tempReviewNum; //reviewNumber.text = rate; //使用者がコメントした内容を表示 myComment.text = drone["mycomment"].ToString(); if (myComment.text == "") { myCommentView.SetActive(false); } if (drone["phone_number"] != null) { phoneNumber.text = "電話番号:" + drone["phone_number"].ToString(); } if (drone["address"] != null) { postCode.text = "所在地:" + drone["address"].ToString(); } string tags = ""; for (int i = 1; i < 6; i++) { if (drone[("tag" + i.ToString())] == null || drone[("tag" + i.ToString())].ToString() == "") { continue; } string str = (drone[("tag" + i.ToString())].ToString()); if (str != null) { Debug.Log(str); if (i != 1) { str = "," + str; } tags = tags + str; } else { } } tagView.text = "tag:" + tags; }