0

post メソッドを使用してこの配列を取得しています。投稿ごとに列数が増加します。

"floor":
[
     {"no_of_bedroom":"1.5","floor_plotsize_start":"692.00","floor_price_start":"4356832.00"},
     {"no_of_bedroom":"2.0","floor_plotsize_start":"1000.00","floor_price_start":"6296000.00"},
     {"no_of_bedroom":"2.0","floor_plotsize_start":"1029.00","floor_price_start":"6478584.00"},
     {"no_of_bedroom":"2.0","floor_plotsize_start":"1132.00","floor_price_start":"7127072.00"},
     {"no_of_bedroom":"3.0","floor_plotsize_start":"1390.00","floor_price_start":"8751440.00"},
     {"no_of_bedroom":"3.0","floor_plotsize_start":"4901.00","floor_price_start":"40801320.00"}
]

Androidで動的テキストビューを使用して表示するには?

JSONArray jsonarray;
jsonarray = jsonobject.getJSONArray("floor");
{
    //How to proceed by using dynamic textview?
}

前もって感謝します

4

3 に答える 3

1

表示したいアイテムのテキストビューでリストビューを作成できると思います

私の提案は、ループを使用してオブジェクトごとに取得し、リストビュー内に配置することです

疑似コード:

for(int i=0; i< jsonarray.size(); i++){
    list.add(jsonarray.getJSONObject(i).getString("no_of_bedroom")); //just an example to check the details of no_of_bedroom key and add it inside the 
}
//using list adapter HERE to display the item the TextView

ぜひお試しいただき、ご希望の方法をお知らせください。

于 2013-08-28T06:04:30.340 に答える
0

これを試して

JSONArray jArray = jsonobject.getJSONArray("floor");

for(int i=0; i < jArray.length(); i++)
{
     TextView textview = new TextView(this);

     textview.setText(""); //your own text

        layoutname.addView(textview);
}
于 2013-08-28T06:38:51.487 に答える
0

必要なテキストビューを動的に作成し、それらをメインのレイアウトとディスプレイに追加できます。以下は、そのための小さなヒントです。

JSONArray jArray = jsonobject.getJSONArray("floor");

for(int i=0; i < jArray.length(); i++)
{
     TextView textview = new TextView();

     textview.setText(""); //your own text
     textview.setTextColor(Color.parseColor("#000000")); //your own color

     //And now add this textview to your main layout 
     yourlayout.addView(textview);
}
于 2013-08-28T06:33:14.097 に答える