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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:49:56+00:00 2026-06-13T13:49:56+00:00

I set one Gribview and one listview in an Activity,In the Gridview there is

  • 0

I set one Gribview and one listview in an Activity,In the Gridview there is a TextView and a Button,What I want do is ,when I click the button ,can add a data to the listView .and the button and listView in different layout files.

the xml code is :

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
  xmlns:android="http://schemas.android.com/apk/res/android"  
  android:id="@+id/root"  
  android:orientation="vertical"  
  android:layout_width="wrap_content"  
  android:layout_height="wrap_content"  
  android:layout_marginTop="5dp"  
  android:descendantFocusability="blocksDescendants" 
  >  



  <ImageView
  android:id="@+id/image"
  android:layout_width="180dp"
  android:layout_height="160dp"
  android:layout_gravity="fill"
  android:padding="4dp"
  android:scaleType="fitXY" />

  <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content">

  <LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content">

  <TextView  
  android:id="@+id/title"  
  android:layout_width="wrap_content"  
  android:layout_height="wrap_content"  
  android:layout_gravity="center"  
  android:gravity="center_horizontal" 
  android:text="prices"  
  />  
  <TextView  
  android:id="@+id/prices"  
  android:layout_width="wrap_content"  
  android:layout_height="wrap_content"  
  android:layout_gravity="center"  
  android:gravity="center_horizontal"  
  android:text="name"  
  />  
  </LinearLayout>
  <LinearLayout android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="9" />
  <Button 
  android:id="@+id/add"  
  android:layout_width="45dip"  
  android:layout_height="45dip"  
  android:layout_gravity="center"  
  android:gravity="center_horizontal" 
  android:text="+" 
  android:layout_weight="0.2"
  android:textSize="12pt"
  />
  </LinearLayout>
</LinearLayout>  

I want to realize when I click the button ,the sequence number of the image I pick can add to the listView.

ADD:

maybe I didn’t say it clear.I have gridView and listView in one layout file.In the gridView I define an layout file ,which contain an ImageView and a Button.What I realize is ,when the app run,I have obtain the button’s action in getView,What I want:in button events ,how to write the position values in listView.I haven’t got the solution yet ,it really bother me ,thankx for any help.

ADD2:

Now I have achieved the adapter.notifyDataSetChanged()adding data in ListView.but I don’t know how to obtain the string variable in Acitivity,the string variable is given by text(TextView android:id="@+id/prices") in ListView to Activity.When I refresh View(adapter.notifyDataSetChanged()),I get “0”. why?could anyone help?thank a lot.

  • 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-13T13:49:57+00:00Added an answer on June 13, 2026 at 1:49 pm

    You’ll need to begin by adding a ListView to your layout file, and adding a button handler.

    Take a look at Dynamically add elements to a listView Android

    This links to a Stack Overflow question/answer that should get you started

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

Sidebar

Related Questions

I want to use the GridView mode of a ListView to display a set
If I want to set both gridview.datasource and gridview.datamember, which one I should set
I add a ButtonField in one Gridview's Column so there is Buttonfield for each
Instead of using an external web-based Mercurial host, I want to set one up
Having a Zend_Form with a Zend_Form_Element_Select on it, i can set ONE option selected
Here i got a problem in my script, Once we set one radio button
In Linux, can one set a custom icon for a folder/directory as it appears
I have a WPF ListView who's view is set to a GridView. Rows in
I'm working on an Android application with ListView/GridView. Since I set an onClickListener on
I want to show list of products in ListView where one of the columns

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.