我不知道为什么但是当我点击列表行时没有发生任何事情,即控件不在list_places.setOnItemClickListener
final ListView list_places=(ListView)findViewById(R.id.list_places);
final ListView list_county=(ListView)findViewById(R.id.list_county);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
//get MapController that helps to set/get location, zoom etc.
mMapController = mapView.getController();
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0L, 50.0f, this);
final List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.mapmarker);
itemizedoverlay = new MyItemizedOverlay(drawable,mapView);
mCurrentLatitude=(double) +28.63144713;
mCurrentLongitude=(double) +77.38672751;
GeoPoint point = new GeoPoint((int)(mCurrentLatitude*1000000),(int)(mCurrentLongitude*1000000));
OverlayItem overlayitem = new OverlayItem(point,null, "Du er her");
itemizedoverlay.addOverlay(overlayitem);
mMapController.animateTo(point);
mMapController.setCenter(point);
mButtonCounty=(Button)findViewById(R.id.bttn_county);
mButtonRadar=(Button)findViewById(R.id.bttn_radar);
mContainer = (ViewGroup) findViewById(R.id.container);
mContainerView=(ViewGroup) findViewById(R.id.container_view);
final Thread dataThread=new Thread(new Runnable() {
public void run()
{
getFiveNearShops();
DataBaseHelper myDbHelper = new DataBaseHelper(mContext);
myDbHelper = new DataBaseHelper(mContext);
try
{
myDbHelper.createDataBase();
}
catch (IOException ioe)
{
throw new Error("Unable to create database");
}
try
{
myDbHelper.openDataBase();
mCountyAndShops = myDbHelper.getCountyList();
}
catch(SQLException sqle)
{
throw sqle;
}
finally
{
myDbHelper.close();
}
}
});
dataThread.start();
Thread displayThread = new Thread(new Runnable() {
public void run() {
try
{
dataThread.join();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
mHandler.post(new Runnable() {
public void run()
{
list_places.setAdapter(new EfficientAdapter(getApplicationContext()));
list_places.setDivider(null);
mapOverlays.add(itemizedoverlay);
list_county.setAdapter(new CountyListEfficientAdapter(getApplicationContext(),mCountyAndShops));
list_county.setDivider(null);
}
});
}
});
displayThread.start();
list_county.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent intent=new Intent("com.similarlayers.finnpolet.ShopList");
intent.putExtra("countyId",mCountyAndShops.get(position)[2]);
intent.putExtra("countyName",mCountyAndShops.get(position)[0]);
Log.v("click","click");
startActivity(intent);
}
});
list_places.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.v("clickplaces","clickplaces");
}
});
答案 0 :(得分:0)
我认为你的list_places不在ui线程中通过你使用mHandler.post,把你的list_places放在你的UI线程中,我认为你应该使用AsyncTask
答案 1 :(得分:0)
我想你可能会导入其他一些图书馆......
导入以下.............
import android.widget.AdapterView.OnItemClickListener;
这是我从List ...
中选择项目的代码 ListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long position) {
Log.d("Current Position u Click", " " + position);
}
});
试试这个......可能是你得到帮助......