---
title: "Setting extra variables to a buttonclicklistener in listview"  
description: "Setting extra variables to a buttonclicklistener in listview"  
author: "Anonymous User"  
published: 2015-01-23  
updated: 2015-01-23  
canonical: https://www.mindstick.com/forum/12898/setting-extra-variables-to-a-buttonclicklistener-in-listview  
category: "mobile development"  
tags: ["android", "java", "android listview"]  
reading_time: 2 minutes  

---

# Setting extra variables to a buttonclicklistener in listview

in my app i have a [listview](https://www.mindstick.com/articles/12744/listview-in-android)([asynctask](https://www.mindstick.com/forum/158886/what-is-the-purpose-of-asynctask-in-android-and-when-should-it-be-used)) getting all the users from [external](https://www.mindstick.com/articles/12810/how-to-connect-tablet-to-external-monitor-or-flat-screen-tv-using-computer-adapters) database. Each row of my listview contains an [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) that the user can interact. When user presses that image i try to start a new [intent](https://www.mindstick.com/forum/33890/examples-of-intent-and-bundles) by using the data that i [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) have(by using putExtra while [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) the intent.) Listview [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why) - it gathers all the [data from database](https://www.mindstick.com/forum/34370/how-to-populate-google-charts-using-data-from-database-created-via-data-first-asp-dot-net-mvc). But, the putExtra [values](https://www.mindstick.com/forum/327/sum-textbox-values) are same for each row. I will appreciate if you can help me regarding that matter.

**Code is as follows; The important part is below**

```
ImageView showlastonmap = (ImageView)v.findViewById(R.id.showlastonmap);where i try to add putExtra. @Override    protected void onPostExecute(JSONObject json) {        pDialog.dismiss();        try {             if (json.getString(KEY_SUCCESS) != null) {                String res = json.getString(KEY_SUCCESS);                 //Invitation count                 Integer inv =  json.getInt("invitation");                setNotifCount(inv);                 if(Integer.parseInt(res) == 1) {                     // Getting JSON Array from URL                     android1 = json.getJSONArray(TAG_LOCATIONDATA);                    for (int i = 0; i < android1.length(); i++) {                        JSONObject c = android1.getJSONObject(i);                         // Storing  JSON item in a Variable                        final String ver = c.getString("username");                         final String dataenlem = c.getString("enlem");                        final String databoylam = c.getString("boylam");                        final String datazaman = c.getString("zaman");                         /*----------to get City-Name from coordinates ------------- */                        StringBuffer address = new StringBuffer();                        Geocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());                        List<Address> addresses;                        try {                            addresses = gcd.getFromLocation(Double.parseDouble(dataenlem), Double.parseDouble(databoylam), 1);                             if (addresses.size() > 0)                               // System.out.println(addresses.get(0).getLocality());
```

## Replies

### Reply by Anonymous User

you should do :

```
 Intent login = new Intent(getApplicationContext(),           HaritaLastSolo.class);         login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);           login.putExtra("enlem",
oslist.get(position).get("enlem"));           login.putExtra("boylam",
oslist.get(position).get("boylam"));         
startActivity(login);
```


---

Original Source: https://www.mindstick.com/forum/12898/setting-extra-variables-to-a-buttonclicklistener-in-listview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
