如何使用符号

时间:2014-08-12 09:01:20

标签: android json

我必须以下面的格式显示详细信息,我的JSON看起来像这样:

{
        "clubs":[
        {
            "title" : "Bold Eyes Night Club",
            "description" : "(Heading 1)Why We Like It (PointNo.1)Cook up your own food in the fully equipped kitchens. (PointNo.2)Up the street's London Bridge. (PointNo.3)Famous food shopping market few steps away from the door. (Heading 2)Need to Know (PointNo.1)All rooms to fit two people. (PointNo.2)18+ to book a room."
        }
    ]
}

如何实现这一目标:

enter image description here

我已经解析了JSON数据,现在我只想以上面屏幕截图所示的格式显示描述

我的意思是new linedotsplus和其他symbols

4 个答案:

答案 0 :(得分:2)

由于您可以控制JSON,请尝试重建JSON,如下所示

{
    "clubs": [
        {
            "title": "Bold Eyes Night Club",
            "description": [
                {
                    "Heading": "Why We Like It",
                    "Points": [
                        "Cook up your own food in the fully equipped kitchens.",
                        "Up the streets London Bridge.",
                        "Famous food shopping market few steps away from the door."
                    ]
                },
                {
                    "Heading": "Need to Know",
                    "Points": [
                        "All rooms to fit two people.",
                        "18+ to book a room."
                    ]
                }
            ]
        }
    ]
}

解析后,设置为TextView。

mHeading.setText(data.getHeading()) // "Why We Like It",
mHeading.setTextSize(24);

String mPoints = ""; mPoint1 +  + 
for(int i = 0; i < data.getPoints().size(); i++)
{
    mPoints = "&emsp;&middot;" + data.getPoints().get(i) + "\n";
}
mPointsTextView.setText(Html.fromHtml(mPoints));

或者您可以从服务器添加符号,这样您就可以获得更多控制权。

{
    "clubs": [
        {
            "title": "Bold Eyes Night Club",
            "description": [
                {
                    "Heading": "Why We Like It",
                    "Points": "&emsp;&middot;Cook up your own food in the fully equipped kitchens.\n &emsp;&middot;Up the streets London Bridge.\n &emsp;&middot;Famous food shopping market few steps away from the door."
                },
                {
                    "Heading": "Need to Know",
                    "Points": "&emsp;&middot;All rooms to fit two people.\n&emsp;&middot;18+tobookaroom."
                }
            ]
        }
    ]
}


mHeading.setText(data.getHeading()) // "Why We Like It",
mHeading.setTextSize(24);

mPointsTextView.setText(Html.fromHtml(mPoints));  //&emsp;&middot;Cook up yo...

答案 1 :(得分:1)

你可以这样点:

在布局中:

<View android:layout_width="15dp"
        android:layout_height="15dp"
        android:background="@drawable/back"
        android:layout_alignParentTop="true"
        android:layout_margin="10dp"
        />

在drawable中:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval"  >
            <solid android:color="#ffaabb"/>

        </shape>
        </item>>

</selector>

输出:

Result

答案 2 :(得分:0)

Android-fonts不支持所有unicode符号。因此,为DejaVuSans.ttf - 字体分配视图/控件。此字体支持所有符号。

示例:

Typeface unicodeFont = Typeface.createFromAsset(getAssets(), "DEJAVUSANS.TTF");
yourView.setTypeface(unicodeFont); 

希望这有助于你

电贺!

答案 3 :(得分:0)

尝试此

的ascii代码
textView.setText("\u2022 this is DOT"); 
textView.setText("\u00B7 this is MIDDLE DOT"); 
textView.setText("\u000A this is new line");