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

  • Home
  • SEARCH
  • 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 8731569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:16:07+00:00 2026-06-13T09:16:07+00:00

In my Android project I have created a ListView and also an onClickListener is

  • 0

In my Android project I have created a ListView and also an onClickListener is also added with it but while running my project the ListView is not responding against my click on it.

Code

public class MyDayListActivity extends ListActivity {

    // JSON Node names
                private static final String TAG_RESULTS = "results";
                private static final String TAG_ID = "id";
                private static final String TAG_NAME = "name";
                private static final String TAG_RATING = "rating";
                private static final String TAG_REFERENCE = "reference";
                private static final String TAG_ICON = "icon";

    // contacts JSONArray
    JSONArray result = null;
    String url,reference;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

         Intent in = getIntent();
         String location = in.getStringExtra("TAG_LOCATION");
         String type = in.getStringExtra("TAG_TYPE");

        // url to make request
        url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query="+type+"+in+"+location+"&sensor=true&key=AIzaSyD38pak_katUfSR92WE2_O2b9y0JSp5htA";
    new LoadData().execute();

    }
class LoadData extends AsyncTask<String, String, String>
    { 
    // Hashmap for ListView
    ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
    protected String doInBackground(String... args) {

    // Creating JSON Parser instance
        JSONParser jParser = new JSONParser();

    // getting JSON string from URL
        JSONObject json = jParser.getJSONFromUrl(url);


        try {
            // Getting Array of Results
            result = json.getJSONArray(TAG_RESULTS);

            // looping through All Contacts
            for(int i = 0; i < result.length(); i++){

                JSONObject c = result.getJSONObject(i);

                // Storing each json item in variable
                String id = c.getString(TAG_ID);
                String name = c.getString(TAG_NAME);
                String icon = c.getString(TAG_ICON);
                reference  = c.getString(TAG_REFERENCE);
                String rating = c.getString(TAG_RATING);


                // creating new HashMap
                HashMap<String, String> map2 = new HashMap<String, String>();

                // adding each child node to HashMap key => value
                map2.put(TAG_ID, id);
                map2.put(TAG_NAME, name);
                map2.put(TAG_ICON, icon);
                map2.put(TAG_RATING, rating);
                map2.put(TAG_REFERENCE, reference);

                // adding HashList to ArrayList
                contactList.add(map2);

                }
        } 
        catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
            }    
        protected void onPostExecute(String file_url) {


         // Updating parsed JSON data into ListView
        ListAdapter adapter1 = new SimpleAdapter(MyDayListActivity.this, contactList,R.layout.listview_item_row,
                new String[] {TAG_NAME}, new int[] {
                        R.id.txtTitle});

        setListAdapter(adapter1);

        // selecting single ListView item

            // Launching new screen on Selecting Single ListItem
        ListView lv1 = getListView(); 

         lv1.setOnItemClickListener(new OnItemClickListener() 
            {

                    public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

                // Starting new intent
                Intent in = new Intent(getApplicationContext(), ProfileViewActivity.class);
                in.putExtra(TAG_REFERENCE, reference);
                startActivity(in);

            }
        });
        }

}
}
  • 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-13T09:16:08+00:00Added an answer on June 13, 2026 at 9:16 am

    getListView().setOnItemLongClickListener(this);
    public boolean onItemLongClick(final AdapterView myadapter, View arg1, final int arg2,
    long arg3) {

    return false;
    }

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

Sidebar

Related Questions

i have created a sample projet in android named 'myProject'. But while i installing
Ok. I'm working on a project, I have already created the listview, but I
I have created one Android Project with Ant build. And also created Test Project
I have created a MazeSolver android app for a school project. I am using
I created an Android project a few months ago and now have to automate
i have one doubt,i have created new project in eclipse with android 2.3.1 and
I have created some aidl files for IPC in my Android project. They compile
Once I have created a project with the Android wizard, how do I change
I currently have an Android project in Eclipse. I created it with a target
i have a created android project and within it i have created two package

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.