Have Complication With Getlistadapter Android?
I want to get latitude and longitude data from sqlite database. So i use this code below, but there is a problem in getListAdapter(). It say that i must create 'getListAdapter()' m
Solution 1:
You do not need to extend ListActivity. You simply need to find the listview and call its getAdapter() method.
Here is your updated code.
publicvoidonItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
//TODO Auto-generated method stubListViewlv= (ListView) findViewById(R.id.YOURLISTVIEW);
StringselectedItem= (String) lv.getAdapter().getItem(position);
Stringquery="SELECT lat, long FROM hoteltbl WHERE name = '" + selectedItem + "'";
SQLiteDatabasedbs= dbHotelHelper.getReadableDatabase();
Cursorresult= dbs.rawQuery(query, null);
result.moveToFirst();
doublelat= result.getDouble(result.getColumnIndex("lat"));
doublelongi= result.getDouble(result.getColumnIndex("long"));
Intentintent=newIntent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr=&daddr="+lat+","+longi));
startActivity(intent);
}
Solution 2:
Your activity should extends ListActivity to have getListAdapter method. Take a look at this tutorial.
If you want to get item, you should use getItem(position) method from adapter which was set to ListView
Post a Comment for "Have Complication With Getlistadapter Android?"