odd long click info

git-svn-id: https://osmand.googlecode.com/svn/trunk@117 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
frolovmo 2010-06-02 15:05:28 +00:00
parent dab9f436cf
commit b9f82208aa
2 changed files with 24 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -13,11 +13,13 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.osmand.Algoritms; import com.osmand.Algoritms;
import com.osmand.OsmandSettings; import com.osmand.OsmandSettings;
@ -72,6 +74,7 @@ public class SearchPOIActivity extends ListActivity {
} }
}); });
Bundle bundle = this.getIntent().getExtras(); Bundle bundle = this.getIntent().getExtras();
String anemity = bundle.getString(ANENITY_TYPE); String anemity = bundle.getString(ANENITY_TYPE);
if (anemity != null) { if (anemity != null) {
@ -92,6 +95,22 @@ public class SearchPOIActivity extends ListActivity {
setListAdapter(amenityAdapter); setListAdapter(amenityAdapter);
} }
} }
// ListActivity has a ListView, which you can get with:
ListView lv = getListView();
// Then you can create a listener like so:
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
Amenity amenity = amenityList.get(pos);
String format = amenity.getSimpleFormat(OsmandSettings.usingEnglishNames(v.getContext()));
if(amenity.getOpeningHours() != null){
format += "\n Opening hours : " + amenity.getOpeningHours();
}
Toast.makeText(v.getContext(), format, Toast.LENGTH_SHORT).show();
return true;
}
});
} }
public void onListItemClick(ListView parent, View v, int position, long id) { public void onListItemClick(ListView parent, View v, int position, long id) {
@ -149,7 +168,11 @@ public class SearchPOIActivity extends ListActivity {
.getLongitude())); .getLongitude()));
String str = anemity.getStringWithoutType(OsmandSettings.usingEnglishNames(SearchPOIActivity.this)); String str = anemity.getStringWithoutType(OsmandSettings.usingEnglishNames(SearchPOIActivity.this));
label.setText(str); label.setText(str);
if(anemity.getOpeningHours() != null) {
icon.setImageResource(R.drawable.poi); icon.setImageResource(R.drawable.poi);
} else{
icon.setImageResource(R.drawable.closed_poi);
}
distanceLabel.setText(" " + dist + " m "); distanceLabel.setText(" " + dist + " m ");
} }
} }