我是Android新手,我想使用JSON从服务器获取数据,并希望安排在列表视图中,但我无法做到这一点。这是链接:i。 http://www.masjid-timetable.com/data/masjids.php! I want to arrange the data in this image format
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
>
<TextView
android:layout_width="376dp"
android:layout_height="45dp"
android:background="@drawable/select_masjid"
android:id="@+id/textView" />
<ImageView
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_marginLeft="2dp"
android:background="@drawable/dashboard_n3"
android:onClick="M"/>
<ImageView
android:layout_width="65dp"
android:layout_height="45dp"
android:layout_marginLeft="300dp"
android:background="@drawable/reload4"
/>
</FrameLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_column="0">
<FrameLayout>
<ImageView
android:layout_width="300dp"
android:layout_height="20dp"
android:background="@drawable/search"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/button_all"
android:layout_marginLeft="310dp"/>
</FrameLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="0dp"
android:layout_marginTop="15dp"
android:layout_column="0">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@android:id/list"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFF"
android:fastScrollEnabled="true"/>
<LinearLayout
android:id="@+id/sideIndex"
android:layout_width="40dip"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
答案 0 :(得分:0)
答案 1 :(得分:0)
首先请使用快速滚动列表视图(不要使用表格视图),即。对于右侧的字母
这里的链接可能会有所帮助:Android ListView with fast scroll and alphabetical section index 和
https://github.com/andraskindler/quickscroll
并且对于json解析,请参考http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
如果您需要更多帮助,请告诉我!!
答案 2 :(得分:0)
如果来自服务器的JSON数据将提供LIstView,那么您最好创建一个将存储列表项数据的数据类,因此在解析JSON时,将每个项目保存到数据类。然后在解析之后,您将获得数据类的List / ArrayList。现在,您可以在ListView中显示数据列表。
答案 3 :(得分:0)
首先创建一个模型类,然后创建一个适配器来绑定响应值,然后您可以使用Volley
,Asynctask
,Retrofit
来解析数据。然后显示它在您的listview
,This正是您所寻找的