android


The method onListItemClick(ListView, View, int, long) of type MainActivity must override or implement a supertype method


I just changed a ListActivity to Activity, and everything works fine except the code that makes the activity do something if click on List Item (onListItemClick).
I get this error:
The method onListItemClick(ListView, View, int, long) of type MainActivity must override or implement a supertype method
#Override
protected void onListItemClick(ListView lv, View v, int position, long id) {
super.onListItemClick(lv, v, position, id);
// Do something
}
( This class was extending ListActivity and everything works fine, but now I want it to extend Activity).
Everything works fine except for this code.
Your issue is that you'd extends as ListActivity and after some time you had removed ListActivity and extend your class to Activity. onListItemClick is an override method of ListActivity which is not available in Activity
Solution : If you want to use ListItemClick in Activity so you can do it by following ways else you need to extends your MainClass with ListActivity instead of Activity
There are 2 ways to setOnItemClickListener to the ListView while using Activity
- Implement OnItemClickListener to your Activity
public class MyActivity extends Activity implements OnItemClickListener {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
}
}
- Write ListView's setOnItemClickListener
mListView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
If you have change from ListActivity to Activity then you have to change onListItemClick to urListView.setOnItemClickListener method. Just Like,
urListView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
}
});

Related Links

Google Play SSL security alert from GameMaker app with Playscape SDK
Android, Fit an Image Inside an ImageView
ListView lagging/jumping when scrolling up
Click event on EditText's drawableRight not working properly?
Draw a shape like this in android
SharedPreference or Sqlite Caching and Network Caching Confusion
Android Studio - Is there any way to add the Module direct from git/svn without storing it locally
SQLite Database - Create new tables and set Table name through a popup
error: cannot find symbol class Android Studio
Check if Bluetooth Device is connected
Import Processing in Eclipse (Android Project)
How to Use Date Picker in Android Fragment?
how do I set up a next and previous button
How to transmit files between two AVDs using TCP?
Fabric/Crashlytics Android adding string resource for Apikey causes Crashlytics Developer Tools Error
Fade out custom view while scrolling

Categories

HOME
sonarqube
phantom-dsl
xml
hyperlink
nunit
numbers
components
sitecore
graphics
boto3
qpython
arangodb
32bit-64bit
little-proxy
stellar.js
nancy
selenium-ide
shared-libraries
3nf
screen-readers
internationalization
mvc-mini-profiler
easyphp
google-container-registry
identity-management
r-mice
tosca
resourcebundle
dynamically-generated
mount
froala
maze
jquery-multiselect
scatter3d
python-2.6
catch-unit-test
sharding
indy10
mnist
navigator
swagger-php
release
bc
tasm
trigonometry
android-softkeyboard
outputcache
clang++
globalize
google-cse
magic-draw
modelsim
truezip
gpg-signature
trigger.io
bootstrap-tags-input
branch-prediction
polyline
autosar
eigenvector
http-status-code-401
bizagi
dynatree
gocql
dllimport
text-search
structuremap3
contrast
machine-instruction
psr-4
paw
wcm
mobility
functional-java
wxformbuilder
dct
android-audiorecord
openargs
high-resolution
epiceditor
cascadingdropdown
http-status-code-410
os.system
pyunit
httponly
fitbounds
relative
matlab-load
webdev.webserver
non-clustered-index
maven-1
aspmenu
application-verifier
httpcookie

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