Note that there are some explanatory texts on larger screens.

plurals
  1. POI click the button ,can add a data to the listView
    text
    copied!<p>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 ,<strong>when I click the button ,can add a data to the listView</strong> .and the button and listView in different layout files.</p> <p>the xml code is :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;ImageView android:id="@+id/image" android:layout_width="180dp" android:layout_height="160dp" android:layout_gravity="fill" android:padding="4dp" android:scaleType="fitXY" /&gt; &lt;LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;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" /&gt; &lt;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" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="0.0dip" android:layout_height="wrap_content" android:layout_weight="9" /&gt; &lt;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" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>I want to realize when I click the button ,the sequence number of the image I pick can add to the listView.</p> <p><strong>ADD:</strong></p> <p>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 ,<strong>how to write the position values in listView</strong>.I haven't got the solution yet ,it really bother me ,thankx for any help.</p> <p><strong>ADD2</strong>:</p> <p>Now I have achieved the <code>adapter.notifyDataSetChanged()</code>adding data in ListView.but I don't know how to obtain the string variable in Acitivity,the string variable is given by text(<code>TextView android:id="@+id/prices"</code>) in ListView to Activity.When I refresh View(<code>adapter.notifyDataSetChanged()</code>),I get "0". why?could anyone help?thank a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload