android


ListView OnItemClickListener doesn't fire


I'm at a loss.
I have a ListView being set via adapter in a fragment.
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_knowledgebase, container, false);
// Set the adapter
mListView = (AbsListView) view.findViewById(R.id.searchResultList);
// Set OnItemClickListener so we can be notified on item clicks
mListView.setOnItemClickListener(this);
mListView.setAdapter(mAdapter);
return view;
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mCallback) {
//call back to activity
mCallback.onFragmentInteraction(position);
}
}
The layout of the list is dead simple. Only 1 text view, no buttons or check boxes.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/searchResultList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:footerDividersEnabled="true"
android:clickable="true"
/>
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="start"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
android:textIsSelectable="false"/>
I've set focusable properties to false and still no dice
The main problem is your variable mCallback is null. So the code below this is not triggering...
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (null != mCallback) {
//call back to activity
mCallback.onFragmentInteraction(position);
}
}
this is almost this
if (null != null) {
to check my answer, try this:
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("ListView OnItemClick","Clicked");
if (null != mCallback) {
//call back to activity
mCallback.onFragmentInteraction(position);
}
}
This will log ListView OnItemClick Clicked
Maybe it should be onListItemClick
#Override
public void onListItemClick(ListView l, View v, int position, long id) {

Related Links

Accessing files under asset subfolder by Id or Name android studio
Center of a cluster of latitude and longitude points in Google map android
Overlaying bitmap over another bitmap
android/ios opening external browser while maintaining controle
Android create a collection which automatic sort new item when add
Updating Parent Fragment from Child Fragment
Quickblox shares users across applications
how to design any screen size and - density in Android(Multi screen for mobiles in Android)
In need of a way to mass configure Android kiosk apps during install
Listview not working for Android Studio
How to reject mobile calls for a time duration in android
How alarmmanager on android schedule the task when using setRepeating when phone shutdown
Android, fast video processing
closeing a service by PendingIntent
How can I resume playing the video in Brightcove Exoplayer when netowrk connection is re-established?
onHandleIntent method is not called on IntentService

Categories

HOME
api
youtube-data-api-v3
swt
mysql-workbench
pdfbox
javacc
cublas
nsbundle
web-hosting
accessibility
watson-conversation
zerobrane
docx
heat
forgot-password
enterprise-miner
solrcloud
sar
google-maps-autocomplete
undertow
ckfinder
dapper-extensions
itunes
beautifier
nstimer
firebase-analytics
sinch
zend-debugger
record
left-join
cart
glib
simplecv
hreflang
android-gridview
gnat-gps
python-import
indy10
sql-delete
yowsup
protege4
sim-toolkit
apic
dm-script
cin
unordered-map
levenshtein-distance
dapper-simplecrud
monkey-testing
snapchat
mongotemplate
google-cse
wpas
java-bytecode-asm
modelsim
java-6
ngmaterial
omxplayer
redistributable
reporting-services-2012
hadoop-2.7.2
nservicebus5
spreadjs
sklearn-pandas
beanstalk
cycle2
relativelayout
dynatree
gocql
file-move
ons-api
pax-exam
uncompress
airbrake
fail2ban
exceldatareader
infosphere-spl
delayed-execution
spy++
kissfft
codeplex
drupal-nodes
solace-mq
nevron
video-codecs
redis-py
window-decoration
qglwidget
updatesourcetrigger
sqlobject
pnrp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App