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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:45:31+00:00 2026-05-29T04:45:31+00:00

Following on from an earlier question I’m trying to get multiple (widgets or in

  • 0

Following on from an earlier question I’m trying to get multiple (widgets or in this case WebViews) inside a GridView.

So I wasn’t really sure how to go about it whether to make my own adapter (seemed scary at the time) or create an ArrayAdapter<WebView>.

I wasn’t really sure if ArrayAdapter could accept it like this or if it only supported primitive types.

GridView contentGrid;
LinearLayout contentLayout;

WebWidget[] webWidgets;

WebWidget web1;
WebWidget web2;
WebWidget web3;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    web1 = new WebWidget(this, "http://www.google.ie");
    web2 = new WebWidget(this, "http://www.facebook.com");
    web3 = new WebWidget(this, "http://www.youtube.ie");

    webWidgets = new WebWidget[]{web1,web2,web3};

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

           //Heres my attempt at an adapter for webview
    ArrayAdapter<WebView> adapter = new ArrayAdapter<WebView>(this,
            android.R.layout.simple_list_item_1, webWidgets);

    contentGrid.setAdapter(adapter);

Unfortunately what comes out is the string version of the WebView.

So question is can I do it this way or am I better of making my own CustomAdapter?

NOTE: Could someone maybe point some information as to what the second constructor variable is? I.E android.R.layout.simple_list_item_1

  • 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-29T04:45:34+00:00Added an answer on May 29, 2026 at 4:45 am

    No matter how you implement your Adapter, you cannot reliably put scrollable widgets in other scrollable widgets, at least where they scroll in the same direction. Since both WebView and GridView scroll vertically, you will get unreliable results trying to combine them this way.

    With that, on to some of your statements and questions:

    I wasn’t really sure if ArrayAdapter could accept it like this or if it only supported primitive types.

    An ArrayAdapter can adapt a Java array or an ArrayList of whatever data type you like.

    Unfortunately what comes out is the string version of the webview…NOTE: Could someone maybe point some information as to what the second constructor variable is? I.E android.R.layout.simple_list_item_1

    The second constructor variable is what you want the cells in your GridView to look like. In your case, you are specifying a built-in layout resource that is a TextView. Hence, you are telling Android you want all your grid cells to be TextView widgets. Android will call toString() on the objects in your array, pour that result into the TextView, and the TextViews will go in your grid cells.

    If you want your ArrayAdapter to be returning things other than a TextView, you will need to override getView() and handle more of that yourself, possibly using a layout file of your own creation.

    So question is can I do it this way or am i better of making my own CustomAdapter?

    As noted at the outset of my answer, what you want simply will not work reliably.

    Pretending for the moment that having WebViews in a GridView would work, the simplest solution would be for you to override getView() in your own subclass of ArrayAdapter, as I mentioned previously. Here is a free excerpt from one of my books that goes over this process.

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

Sidebar

Related Questions

Following up from an earlier question on extracting the n'th regex match , I
Following on from my earlier question , I am still having issues with loading
Following on from my earlier question, I have decided to have a go at
(Split from an earlier question). Does anyone know what's going on here? The following
Following up from the question I made earlier, I made the query below but
This is a split from discussion on earlier question. Suppose I need to define
I'm following up on my earlier question: Mono.Cecil: call base class' method from other
Following on from my earlier question around loading views from DLLs under ASP.NET MVC,
Following on from my earlier question: Manipulate Lucene query before performing search I've run
Following from my last question which @Jon Skeet gave me a lot of help

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.