Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Mobile App Development Assignment). Note: Please write the Java and XML code(s)

ID: 3910376 • Letter: #

Question

(Mobile App Development Assignment).

Note: Please write the Java and XML code(s) if you are going to answer the problem. Also, please give me a link of where you got the images from.

Problem 1 - Customize a content display with GridView

We have gone through the process of creating a customized display with a ListView.
(Figure 1) For each list item, you have one ImageView and two TextView. We created a ListAdapter
object to manage ListView content. Because we needed to present a complicated data,
ArrayAdapter<T> is extended.

? 5:45 12:17 GridView Customized_Layout ListView Customized_Layout David Boston is not snowing now Cooper The design is so cool Title-1 2018-02-25 Title-2 2018-02-25 Title-3 2018-02-25 Jones like hacking. Do you like it? Title-4 2018-02-25 Title-5 2018-02-25 2018-02-25 Title-7 2018-02-25 itle-8 2018-02-25 itle-9 2018-02-25 itle-10 itle-11 Title-12 Figure 1: Expected result of Problem 2 in Lab 6 Figure 2: Expected result of this Lab implementation of GridView the

Explanation / Answer

Mobile App Development Assignment(Grid Images)-

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  xmlns:tools="http://schemas.android.com/tools"

    android:layout_height="fill_parent"

    android:layout_width="fill_parent"

   

    tools:context=".MainActivity" >

    <GridView

         android:layout_width="fill_parent"

         android:layout_height="fill_parent"

         android:numColumns="auto_fit"

         android:gravity="center"

         android:columnWidth="98dp"

         android:stretchMode="columnWidth"

        

         android:id="@+id/mygrid"

         />

</LinearLayout>

Single_grid.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_height="wrap_content"

    android:layout_width="wrap_content"

    android:padding="6dp" >

    <ImageView

        android:layout_width="48dp"

        android:id="@+id/image_grid"

        android:layout_height="48dp">    

    </ImageView>

    <TextView

        android:id="@+id/text_grid"

        android:layout_height="wrap_content"

        android:layout_width="wrap_content"

        android:layout_marginTop="17dp"

        android:textSize="8sp" >

    </TextView>

</LinearLayout>

Grid_custom.java

package com.customlist.customgrid;

import android.content.Context;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.BaseAdapter;

import android.widget.ImageView;

import android.widget.TextView;

public class Grid_Custom extends BaseAdapter{

            private Context context;

            private final String[] today_date;

            private final int[] id_image;

                public CustomGrid(Context a,String[] today_date,int[]id_image) {

                    context = a;

                    this. id_image = id_image;

                    this.today_date = today_date;

                }

                 @Override

                        public Object getItem(int position) {

                                    // TODO Auto-generated method stub

                                    return null;

                        }

                        @Override

                        public int getCount() {

                                    // TODO Auto-generated method stub

                                    return today_date.length;

                        }

                       

                        @Override

                        public long getItemId(int position) {

                                    // TODO Auto-generated method stub

                                    return 0;

                        }

                        @Override

                        public View getView(int position, View View_convert, ViewGroup parent) {

                                    // TODO Auto-generated method stub

                                    View grid1;

                                    LayoutInflater li = (LayoutInflater) context

                                                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    if (View_convert == null) {

                        grid1 = new View(context);

                                                grid1 = if.inflate(R.layout.single_grid, null);

                        TextView textView = (TextView) grid1.findViewById(R.id.text_grid);

                        ImageView imageView =(ImageView)grid1.findViewById(R.id. image_grid);

                        textView.setText(today_date[position]);

                        imageView.setImageResource(Imageid[position]);

                    } else {

                        grid1 = (View) View_convert;

                    }

                                    return grid1;

                        }

}

MainActivity.java

package com.customlist.customgrid;

import android.os.Bundle;

import android.app.Activity;

import android.view.View;

import android.widget.AdapterView;

import android.widget.GridView;

import android.widget.Toast;

public class MainActivity extends Activity {

            GridView grid1;

String date_current = new SimpleDateFormat("dd-MM-yyyy").format(new Date());

            String[] today_date = {

                        date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current, date_current,

            } ;

            int[] id_image = {

                                    R.drawable.your_image1,

                                    R.drawable.your_image2,

                                    R.drawable.your_image3,

                                    R.drawable.your_image4,

                                    R.drawable.your_image5,

                                    R.drawable.your_image6,

                                    R.drawable.your_image7,

                                    R.drawable.your_image8,

                                    R.drawable.your_image9,

                                    R.drawable.your_image10,

                                    R.drawable.your_image11,

                                    R.drawable.your_image12,

                                    R.drawable.your_image13,

                                    R.drawable.your_image14,

                                    R.drawable.your_image15

            };

            @Override

            protected void onCreate(Bundle savedInstanceState) {

                        super.onCreate(savedInstanceState);

                        setContentView(R.layout.activity_main);

                        CustomGrid my_adapter = new CustomGrid(MainActivity.this, today_date, id_image);

                        grid1=(GridView)findViewById(R.id.grid1);

                                                grid1.setAdapter(my_adapter);

                                                grid1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                                    @Override

                                    public void onItemClick(AdapterView<?> parent, View view,

                                                            int position, long id) {

                                        Toast.makeText(MainActivity.this, “This is ”+ today_date [+ position], Toast.LENGTH_SHORT).show();

                                    }

                                });

            }

}

Manifest File

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.customlist.customgrid"

    android:versionCode="1"

    android:versionName="1.0" >

    <uses-sdk

        android:minSdkVersion="8"

        android:targetSdkVersion="18" />

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/your_app_name"

        android:theme="@style/Your_AppTheme" >

        <activity

            android:name=" com.customlist.customgrid.MainActivity"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>

</manifest>