0

I have this XML file which has a grid view

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
            app:layout_scrollInterpolator="@android:anim/linear_interpolator"
            app:toolbarId="@+id/toolbar">

            <ImageView
                android:id="@+id/app_bar_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/action_poster"
                android:transitionName="typeImage"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"></android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">



            <RelativeLayout
                android:layout_width="368dp"
                android:layout_height="0dp"
                tools:layout_editor_absoluteY="275dp"
                tools:layout_editor_absoluteX="8dp">

                <GridView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="80dp"
                    android:columnWidth="80dp"
                    android:gravity="center"
                    android:numColumns="auto_fit"
                    android:stretchMode="columnWidth">

                </GridView>

            </RelativeLayout>



    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

Aand here is each item of the grid:

class GridViewcustomadapter extends ArrayAdapter {
    Context context;


    public GridViewcustomadapter(Context context) {
        super(context, 0);
        this.context=context;
    }

    public int getCount(){
        return 24;
    }

How can I fill this grid with data from my tables in WAMP server which has table has an image and title?

  • Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) and [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) and how to create a [Minimal, Complete and Verifiable example](http://stackoverflow.com/help/mcve) **SO is not** a free Coding or Code Conversion or Debugging or Tutorial or Library Finding service ___We try to fix your code, we do not write your code___ – RiggsFolly May 12 '17 at 13:00

1 Answers1

0

First of all you need to learn how to make a HTTP request to get data from either local or remote server. There is alot of awesome library such as Retrofit, Android volley , OKHTTP which make HTTP request easier.

  1. Volley
  2. Retrofit
  3. OKHTTP

If you don't understand why you need to make HTTP request, it basically getting or sending data from a web server. So if you make a request to your own mamp server you will get all yours HTML code of that specific page.

For how to fill your gridview with the data from your tables in wamp server. You need to consider make another file which will return JSON format of your image for example

{
    title:"Stackoverflow",
    image:"https://www.example.com/stackoverflow.png"
}

Try to not parse HTML code because it is kinda headache although there is library call jsoup which make parse XML alot easier but still if you have a choice try to make your server return JSON or XML.

teck wei
  • 1,375
  • 11
  • 22