Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get my ListView items to be highlighted when they are selected
    text
    copied!<p>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? </p> <pre><code>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&lt;?&gt; 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&lt;HashMap&lt;String,String&gt;&gt; jobsList; public JobItemAdapter(Context context, List&lt;HashMap&lt;String,String&gt;&gt; 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; } } } </code></pre>
 

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