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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:24:27+00:00 2026-05-26T14:24:27+00:00

I want gridview with buttons. following is the code of main page. GridView gridview1

  • 0

I want gridview with buttons. following is the code of main page.

    GridView gridview1 = (GridView) findViewById(R.id.gridview);    
    gridview1.setAdapter(new Buttonadapter(this));
    gridview1.setOnItemClickListener(new OnItemClickListener() 
    {       
    public void onItemClick(AdapterView<?> parent, View arg1, int position, long id)
                       {  

                TextView temp=(TextView)arg1;  
                CharSequence  temp2=temp.getText(); 
                Intent myIntent = new Intent(arg1.getContext(), Diseasemain.class);
                myIntent.putExtra("disease", temp2);
                startActivityForResult(myIntent, 0);
                }
    });

here is the code of buttonadapter class

public class Buttonadapter  extends BaseAdapter {
private Context mContext;   
public Buttonadapter(Context c) 
{        mContext = c;    }    
public int getCount() 
{        return mThumbIds.length;    }   
public Object getItem(int position) 
{        return null;    }    
public long getItemId(int position)
{        return 0;    }    // create a new ImageView for each item referenced by the Adapter    
public View getView(int position, View convertView, ViewGroup parent) 
{        Button btn;        
        if (convertView == null) 
        {  // if it's not recycled, initialize some attributes          
            btn = new Button(mContext); 
            btn.setOnClickListener(new View.OnClickListener() { 
                public void onClick(View v) { 
                    // Perform action on click 
                 } 
             }); 

    btn.setLayoutParams(new GridView.LayoutParam(85,85));           
            btn.setPadding(8, 8, 8, 8);       
            } 
        else 
        {           
            btn = (Button) convertView;       
            }       
        btn.setText(mThumbIds[position]);      
        return btn;    }  

private String[] mThumbIds =
    {           
        "hi",
        "bye",
        "heelo"
        }
;}

the problem is whenever I click on any button its not firing the onclick event nd not starting the next page also.

  • 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-26T14:24:28+00:00Added an answer on May 26, 2026 at 2:24 pm

    looks like the empty onclick method in your adapter is stopping
    the itemclick listener from firing.
    Try putting the code that starts the next page in the onclick instead.

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

Sidebar

Related Questions

I am using C#.net I want to add custom edit/delete buttons to my GridView1
I have multiple radio buttons columns in my gridview, I want to select one
Disable a post back from asp.net i.e. buttons, links, gridview page index changing and
I have the following code in xaml: <ListView Name=listView1 IsSynchronizedWithCurrentItem=True > <ListView.View> <GridView> <GridViewColumn
I have defined a nested grid view in the following way. <asp:GridView ID=GridView1 runat=server
I have a gridview and I add some buttons programmatically to this grid. I
I have the following image button on the GridView and I want to call
I'm using the following code to highlight the selected row in a gridview. I
I have gridview binded from database.. I have following code: protected void Page_Load(object sender,
I am very new in j2me. I want to design following type layout and

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.