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 9216793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:29:32+00:00 2026-06-18T02:29:32+00:00

how to clear the gridview when i request for another adapter if i use

  • 0

how to clear the gridview when i request for another adapter if i use the lazy adapter here i put my code for gridview activity and lazyadapter i m use the asynctask for gridview items

here i put my code for gridview

Gridview Activity.java

public class VisitorActivity extends Activity implements OnClickListener{
{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new visitormiddlelistasyntask.execute(""); 
       }   

public class VisitorMiddleListAsyncTask extends AsyncTask<String,ArrayList<HashMap<String, String>>,ArrayList<HashMap<String, String>>>
    {
        String city;
        JsonParser jparser=new JsonParser();
        String visitorurl="http://digitalhoteladnetwork.com/vixxa_beta/index.php/visitors/webvisitorlist";
        //String visitorurl="http://digitalhoteladnetwork.com/vixxa_beta/index.php/visitors/websearch_visitor_guide";

        @Override
        protected ArrayList<HashMap<String, String>> doInBackground(String... params) 
        {
            //For Get city

            Geocoder geocoder = new Geocoder(VisitorActivity.this, Locale.getDefault());
            try
            {
                List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
                Log.e("Addresses","-->"+addresses);
                city = addresses.get(0).getSubAdminArea();
               // Log.e("Cityname","--->"+city);

            }
            catch (IOException e)
            {
                e.printStackTrace();
              //  Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
            }


                    WebServiceData wsd=new WebServiceData();

                    String visitorstring=wsd.VisitorGuide(city, visitorurl);

                    //Log.e("webservice visitorstring","-->"+wsd.VisitorGuide(city, visitorurl));

                Log.e("webservice visitorstring","-->"+visitorstring);



                    try
                    {
                        JSONObject jobject=new JSONObject(visitorstring);
                        JSONArray jvisitorlist=jobject.getJSONArray(TAG_VISITORGUIDELIST);

                        for(int i=0;i<jvisitorlist.length();i++)
                        {
                            HashMap<String, String> map=new HashMap<String, String>();

                            String id=jvisitorlist.getJSONObject(i).getString(TAG_VISITORGUIDEID).toString();
                            //Log.e("Id","-->"+id);

                            String title=jvisitorlist.getJSONObject(i).getString(TAG_VISITORGUIDETITLE).toString();
                            //Log.e("Title","-->"+title);

                            String image=jvisitorlist.getJSONObject(i).getString(TAG_VISITORGUIDEIMAGE).toString();
                            //Log.e("Image","-->"+image);

                            //String show=jvisitorlist.getJSONObject(i).getString(TAG_VISITORTITLESHOW).toString();

                            map.put(TAG_VISITORGUIDEID,id);
                            map.put(TAG_VISITORGUIDETITLE,title);
                            map.put(TAG_VISITORGUIDEIMAGE, image);
                            //map.put(TAG_VISITORTITLESHOW,show );

                            visitormiddle.add(map);

                        }

                        //Log.e("Visitor Guide List","-->"+jvisitorlist);

                    }
                    catch (Exception e)
                    {
                            e.printStackTrace();
                    }

                    return visitormiddle;

        }

        protected void onPostExecute(ArrayList<HashMap<String, String>> result)
        {

            gridview=(GridView)findViewById(R.id.gridview);
            adapter=new LazyAdapter(VisitorActivity.this, visitormiddle);
            gridview.setAdapter(adapter);

        }


    }


}

LazyAdapter.java

public class LazyAdapter extends BaseAdapter {

    private static final String TAG_VISITORGUIDELIST="visitorlist";
    private static final String TAG_VISITORGUIDEID="visitor_guide_id";
    private static final String TAG_VISITORGUIDETITLE="visitor_guide_cat_title";
    private static final String TAG_VISITORGUIDEIMAGE="visitor_guide_cat_image";
    //private static final String TAG_VISITORTITLESHOW="visitor_guide_cat_titleshow";

    private Activity activity;

    private ArrayList<HashMap<String, String>> result; 
    private static LayoutInflater inflater=null;
    public GridImageLoader gridimageLoader; 

    public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> r) {
        activity = a;
        result=r;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        gridimageLoader=new GridImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return result.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public static class ViewHolder{
        public TextView text;
        public ImageView image;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        ViewHolder holder;
        if(convertView==null){
            vi = inflater.inflate(R.layout.griditem, null);
            //vi = inflater.inflate(R.layout.griditem,parent,false);
            holder=new ViewHolder();
            holder.text=(TextView)vi.findViewById(R.id.textview);;
            holder.image=(ImageView)vi.findViewById(R.id.imageview);
            vi.setTag(holder);
        }
        else

            holder=(ViewHolder)vi.getTag();


        holder.text.setText(result.get(position).get(TAG_VISITORGUIDETITLE));
        holder.image.setTag(result.get(position).get(TAG_VISITORGUIDEIMAGE));
        gridimageLoader.DisplayImage(result.get(position).get(TAG_VISITORGUIDEIMAGE), activity, holder.image);
        return vi;
    }
}
  • 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-06-18T02:29:33+00:00Added an answer on June 18, 2026 at 2:29 am

    You can use ArrayAdapter and then call adapter.clear() to clear the grid view and then refill it with new data.

    You can use same VisitorMiddleListAsyncTask to fill the data again.

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

Sidebar

Related Questions

GridView CurrentGrid =Grd_UserList; Grd_UserList.Columns.Clear(); ı have got this example, ı use Columns.Clear(); fonc. with
I have built a dynamic gridview using the following code grdVariants.Columns.Clear(); int i =
I have Gridview in my activity. Data adapter for my GridView: private class EfficientAdapter
I am using the below code to export gridview to PDF form1.Controls.Clear(); form1.Controls.Add(GridView1); StringWriter
I have Gridview like this. Here is my last column Gridview code; <EditItemTemplate> <asp:TextBox
I have a Clear button which sets the gridview datasource to null and binds
Not clear on some fundamental syntax here. define-key accepts a set of inputs, one
I have a javascript function to clear my form which includes a gridview, I
I want to covnvert GridView data to Excel sheet. I have written the code
I am trying to export a gridview's contents to excel. I have some code:

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.