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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:55:02+00:00 2026-06-08T12:55:02+00:00

I have add buttons in GridView using base adapter, that buttons depend on word

  • 0

I have add buttons in GridView using base adapter, that buttons depend on word length when click the button then hide. After clicking all buttons the GridView is make empty i want to check, if GridView is Empty Display another buttons. I want to check whether GridView is empty or not in GridViewActivity.java

Here is the code.

GridViewActivity.java

public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.spellword);

        txt=(TextView)findViewById(R.id.txtview);
        image=(ImageView)findViewById(R.id.imgview1);

        map.put("melon", R.drawable.melon);
        image.setImageResource(map.get("melon"));


        gridView=(GridView)findViewById(R.id.grid1);
        gridView.setAdapter(new SpellAdapter(this,words,word));

        detector = new SimpleGestureFilter(this, this);

    }

SpellAdapter.java

public class SpellAdapter extends BaseAdapter{

    public Context context;
    public char[] word;

    public SpellAdapter(Context context, char[] word, String orglWord)
    {
        this.context=context;
        this.word=word;

    }

    public int getCount() {
        count=word.length;
        return count;
    }

    public Object getItem(int position) {

        return null;
    }

    public long getItemId(int position) {

        return 0;
    }


    public View getView(final int position, View convertView, ViewGroup arg2) {

        View v = convertView;
        if (v == null) 
        {  
             LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
             v = vi.inflate(R.layout.buttonlist, null);
        } 

        final Button btn= (Button)v.findViewById(R.id.letterbtn);

        btn.setText(word[position]+"");

        btn.setOnClickListener(new OnClickListener(){

            public void onClick(View v) 
            {
                letters=btn.getText();
                String word = letters.toString();
                btn.setVisibility(View.GONE);

            }


        });

        return v; 
    }




}
  • 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-08T12:55:03+00:00Added an answer on June 8, 2026 at 12:55 pm

    if (gridView.getChildCount() == 0) {...}

    If this doesn’t work try:

    if (SpellAdapter.isEmpty()) {...} Or I think you would need to do something like:

    if (gridView.getAdapter().isEmpty()) {...}

    You can find this info here and here

    Edit:

    Oh I think I see what you mean now. You just hide the button, you don’t remove it. So you will need to use a loop. First, get the number of child count. Then do a for, like:

    for ( int x = 0; x < childcount; x++)

    Inside the for you use View v = gridView.getChildAt(x);

    Then you do if (v instanceof Button) and inside the if you check if the button is visible or not. If it is visible, set false inside a variable like boolean gridViewEmpty and break the loop. Else, set gridViewEmpty to true and then display your other buttons.

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

Sidebar

Related Questions

I've got a gridview that renders as a table. I have an Add button
I have one GridView and one Add Button. If I click the Add button,
I have a code in jquery mobile that will add buttons dynamically in a
I have two validation groups: parent and child I have an add button that
Basically I have a webcontrol that contains a gridview with an export button. When
I have a gridview with a column of asp buttons that I toggle the
I am using DevExpress's GridView. I have edit button working fine. I need to
I have multiple buttons in gridview. How can i determine which particular button on
I have a gridview that is using a LinqDataSource for it's datasource. I've added
I have a gridview that displays the contents of a database table, using an

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.