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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:36:47+00:00 2026-05-20T00:36:47+00:00

I have an app that hits a REST service, gets some json and then

  • 0

I have an app that hits a REST service, gets some json and then places it into a listview. My main activity extends Activity and not ListActivity. I can scroll through the list items, but I cannot select any (at least by touch). I get to the listview through findViewBYId and have an adapter that extends SimpleAdapter. I have set the convertView inside the adapter’s getVIew() as clickable. However when I do this, I can no longer click on the list items in the listView? Did I do this wrong?

public class App extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        jobsListView = (ListView) findViewById(R.id.jobs_list);
        jobsListView.setAdapter(new JobItemAdapter(jobsListView.getContext(), 
                jobsList, 
                R.layout.list_item, 
                new String[] {"title","location"},
                new int[] {R.id.job_title, R.id.job_location}));
        jobsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
                Log.i("jobsListView.setOnItemClickListener()"," item clicked: " + arg0.getSelectedItemPosition());
            }

        });

    }

    public class JobItemAdapter extends SimpleAdapter {
        private List<HashMap<String,String>> jobsList;

        public JobItemAdapter(Context context, List<HashMap<String,String>> jobs, int resource, String[] from, int[] to)
        {   
            super(context, jobs, resource, from, to);
            jobsList = jobs;            
        }

        public View getView(int position, View convertView, ViewGroup parent){
            Log.i(TAG," in  JobItemAdapter getView() ");

            if (convertView == null) {
                //no previous views, inflate views
                convertView = getLayoutInflater().inflate(R.layout.list_item, parent, false);
            }

            //update textviews in layout
            TextView title = (TextView)convertView.findViewById(R.id.job_title);
            title.setText(jobsList.get(position).get("title"));

            TextView location = (TextView)convertView.findViewById(R.id.job_location);
            location.setText(jobsList.get(position).get("location"));
            //make the view clickable
            convertView.setClickable(true);
            return convertView;
        }

    }

}
  • 1 1 Answer
  • 2 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-20T00:36:47+00:00Added an answer on May 20, 2026 at 12:36 am

    Probably what can be happening is that you are defining a background color for the row, defined in R.layout.list_item, and that background color is not a color defined in a selector, for example:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" > 
            <shape android:shape="rectangle"> 
                <solid
                    android:color="@color/blue_button_press"/> 
            </shape> 
        </item> 
        <item android:state_selected="true" > 
            <shape android:shape="rectangle"> 
                <solid
                    android:color="@color/blue_button_focus" /> 
            </shape> 
        </item> 
        <item android:state_focused="true" > 
            <shape android:shape="rectangle"> 
                <solid
                    android:color="@color/blue_button_focus" /> 
            </shape> 
        </item> 
        <item> 
            <shape android:shape="rectangle" >
                <solid
                    android:color="@color/white" /> 
            </shape> 
        </item> 
    </selector>
    

    In it, you can define the color for each state of the View, in this case: focused and pressed.
    In order to use it, in R.layout.list_item, you set the background normaly, for example

    android:background="@drawable/list_row_background"
    

    considering that the xml file file described aboved is named list_row_background and its in the drawable folder

    And you shouldn’t set it as clickable, since it is already clickable.
    I hope that solves your problem 😀
    Cheers

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

Sidebar

Related Questions

I have a app that loads some json from my php web service. This
I have an app that received JSON data from the server. Currently when I
I have an app that allows users to upload large data files and then
I have a C# app that hits a couple of different databases to do
I have an application built that hits a third party company's web service in
I am making an app that will have images. When the user hits the
I have an idea to write a note-taking app in Java that does some
I have a WPF app that uploads XML data to a web service asynchronously.
I have an app that every so often hits a ESE database quite hard
I have a basic web app that given a url, hits a database, does

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.