Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6686497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:10:43+00:00 2026-05-26T05:10:43+00:00

I want to add a GirdView inside a ListView ? Is it possible ?

  • 0

I want to add a GirdView inside a ListView ? Is it possible ? where I set a different adapter for each

edit // upon the following code (gridView) deosn’t appear why?

this is thew adapter for GridView

package com.android.utils;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.uis.R;


public class TimesAdapter extends BaseAdapter {

    private ArrayList<String> listTitle;
    private ArrayList<String> listDates;
    private Activity activity;

    public TimesAdapter(Activity activity, ArrayList<String> listDates,ArrayList<String> listTitle){
        this.listTitle=listTitle;
        this.listDates=listDates;
        this.activity=activity;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder view;
        LayoutInflater inflator = activity.getLayoutInflater();
        if(convertView==null){
            view = new ViewHolder();
            //inflate : inflate xml resources into object
            convertView = inflator.inflate(R.layout.gridview_times_row, null);
            view.tvTitle=(TextView) convertView.findViewById(R.id.tvTitle);
            view.tvDate=(TextView) convertView.findViewById(R.id.tvDate);

            convertView.setTag(view);

        }else{
            view = (ViewHolder) convertView.getTag();
        }
        view.tvTitle.setText(listTitle.get(position));      
        view.tvDate.setText(listDates.get(position));
        return convertView;
    }

    static class ViewHolder{
        public TextView tvTitle;
        public TextView tvDate;
    }

}

This is the class of ListView(that show a GridView) with it’s adapter class

package com.android.uis;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.classes.Appointment;
import com.android.database.DatabaseHelper;
import com.android.networkservices.TimeTableWebService;
import com.android.utils.TimesAdapter;

public class DaysActivity extends Activity {
    private ListView lvDay;
    private Button bUpdateTimeTable,bChangeDate;
    private ArrayList<String> items;
    private ArrayList<Appointment> appointments;
    private ArrayList appointmentsArray[] = new ArrayList[7];
    private EfficientAdapter adap;
    private int mYear;
    private int mMonth;
    private int mDay;
    static final int DATE_DIALOG_ID = 0;
    private Activity activity;
    int dayIndex;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.day_layout);
        lvDay = (ListView)this.findViewById(R.id.lvDay);
        bUpdateTimeTable = (Button)this.findViewById(R.id.bUpdateTimeTable);
        bChangeDate = (Button)this.findViewById(R.id.bChangeDate);
        items = new ArrayList<String>();
        appointments = new ArrayList<Appointment>();
        lvDay.setClickable(true);
        activity = this;

        if(getIntent()!=null)
            if(getIntent().getExtras()!=null)
                if(getIntent().getExtras().getString("day")!="")
                    dayIndex = Integer.parseInt(getIntent().getExtras().getString("day"));
                else
                    dayIndex = -1;
            else
                dayIndex = -1;
        else
            dayIndex = -1;
        Log.d("dayIndex",dayIndex+"");
        bindList(dayIndex);// to bind list items


        lvDay.setOnItemClickListener(new OnItemClickListener(){
            public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

            }
        });
        bUpdateTimeTable.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                DatabaseHelper db = new DatabaseHelper(getApplicationContext());

                // At first delete the previous data then retrieve the new one 
                    db.deteleAllAppointments();
                    appointments.clear();
                    items.clear();

                    TimeTableWebService ttws = new TimeTableWebService();
                    ttws.execute("http://mmu4bader.com/AppointmentJSon/getAppointments1");
                    ttws.getResult(getApplicationContext());
                    //bindList();
            }

        });
        bChangeDate.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                showDialog(DATE_DIALOG_ID);
                Toast.makeText(getApplicationContext(), "date", Toast.LENGTH_SHORT).show();
            }
        });
        // get the current date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        // display the current date (this method is below)
        updateDisplay();


    }
    private DatePickerDialog.OnDateSetListener mDateSetListener =
            new DatePickerDialog.OnDateSetListener() {

                public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) {
                    mYear = year;
                    mMonth = monthOfYear;
                    mDay = dayOfMonth;
                    updateDisplay();
                }
    };
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DATE_DIALOG_ID:
            return new DatePickerDialog(this,mDateSetListener,mYear, mMonth, mDay);
        }
        return null;
    }
    private void updateDisplay() {
        // TODO Auto-generated method stub

    }
    private void bindList(int DayIndex){
        DatabaseHelper db = new DatabaseHelper(getApplicationContext());
        ArrayList<Appointment> tempAppointments = db.getAllAppointments();

        for(int i=0;i<tempAppointments.size();i++)
        {
            Date currentDate = new Date();// get current date
            Date eventDate = tempAppointments.get(i).mStartDate;
        //  int dateEqual = getZeroTimeDate(currentDate).compareTo(getZeroTimeDate(eventDate));

        //  Log.d("event day index",eventDate.getDay()+" "+eventDate);
        //  Log.d("current day index",currentDate.getDay()+" "+currentDate);

            if(eventDate.getDay()==DayIndex)
            {
                items.add(String.valueOf(tempAppointments.get(i).mTitle));
                appointments.add(tempAppointments.get(i));

            }

        }

        adap = new EfficientAdapter(this);
        adap.notifyDataSetChanged();
        lvDay.setAdapter(adap);
    }
    public static Date getZeroTimeDate(Date fecha) {
        Date res = fecha;
        Calendar calendar = Calendar.getInstance();

        calendar.setTime( fecha );
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        res = calendar.getTime();

        return res;
    }
    public void onResume() {
        super.onResume();
    }
    public class EfficientAdapter extends BaseAdapter implements Filterable{

        LayoutInflater inflater;
        Context context;

        public EfficientAdapter(Context context){
            inflater = LayoutInflater.from(context);
            this.context = context;
        }


        public int getCount() {
            // TODO Auto-generated method stub
            return items.size();
        }


        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return items.get(position);
        }


        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return 0;
        }


        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            ArrayList<String> listDates = new ArrayList<String>();
            ArrayList<String>listTitle = new ArrayList<String>();
            listDates.add("17/5/1987");
            listTitle.add("Gaza");
            if(convertView == null){
                convertView = inflater.inflate(R.layout.adaptor_timetable_content, null);
                holder = new ViewHolder();

                holder.gvDates = (GridView)convertView.findViewById(R.id.gvDates);
                holder.textLineTitle = (TextView)convertView.findViewById(R.id.textLineTitle);
                holder.textLineTime = (TextView)convertView.findViewById(R.id.textLineTime);

                convertView.setOnClickListener(new OnClickListener() {
                    private int pos = position;

                        public void onClick(View v) {
                        /*  Intent i = new Intent(context,RoutingMapActivity.class);
                            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            i.putExtra("Department", depts.get(pos).toBunlde());
                            getApplicationContext().startActivity(i);  */                       
                            }
                        });


                convertView.setTag(holder);
            }else{
                holder = (ViewHolder)convertView.getTag();
            }
            // Bind the data efficiently with the holder.
            try{

                holder.textLineTitle.setText(String.valueOf(appointments.get(position).mTitle));
                holder.textLineTime.setText(String.valueOf(appointments.get(position).mStartDate));
                holder.gvDates.setAdapter(new TimesAdapter(activity,listDates,listTitle));
                Log.d("-----adapter",listDates.size()+"");
                holder.gvDates.setOnItemClickListener(new OnItemClickListener() {
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                        // show time info.
                    }
                });

            }catch(Exception ex){

            }
            return convertView;
        }


        public Filter getFilter() {
            // TODO Auto-generated method stub
            return null;
        }


    }
    static class ViewHolder {
        TextView textLineTitle;
        TextView textLineTime;
        GridView gvDates;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:10:43+00:00Added an answer on May 26, 2026 at 5:10 am

    Your TimesAdapter does not contain any data. The getCount() method always returns 0 which is telling the OS that there are no entries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a column to a gridview which contains button control. I
I have a gridview which is databound, I want to dynamically add a row
How can I generate different events from two button columns in gridview? I want
I've been using some code very similar to the following to populate a gridview
I had gridview whch bind datasource and I add edit command to gridview to
work on asp.net vs05.i want to set mouse event on gridview Then based on
I have a gridview and I want to add rows in it dynamically. I
I have a GridView and I want to add some more parameters to the
I have a GridView with a header and some rows and want to add
I am new in C#.I want to add rows in a GridView in runtime.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.