Added pop-up menu for list view

This commit is contained in:
unknown 2014-06-13 18:48:56 +03:00
parent a8f7c49d3a
commit a39298da7c
3 changed files with 36 additions and 11 deletions

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/one"
android:title="@string/route_step_menu_mark_as_next"/>
<item
android:id="@+id/two"
android:title="@string/route_step_menu_show_on_map"/>
</menu>

View file

@ -1876,4 +1876,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="av_photo_play_sound">Play sound on photo shot</string> <string name="av_photo_play_sound">Play sound on photo shot</string>
<string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string> <string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string>
<string name="navigation_intent_invalid">Invalid format: %s</string> <string name="navigation_intent_invalid">Invalid format: %s</string>
<string name="route_step_menu_mark_as_next">Mark as next</string>
<string name="route_step_menu_show_on_map">Show on map</string>
</resources> </resources>

View file

@ -7,10 +7,7 @@ import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.*;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.*; import android.widget.*;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
@ -22,7 +19,7 @@ import java.io.File;
import java.util.*; import java.util.*;
/** /**
* Created by Barsik on 13.06.2014. * Created by Bars on 13.06.2014.
*/ */
public class RouteStepsActivity extends SherlockFragmentActivity { public class RouteStepsActivity extends SherlockFragmentActivity {
@ -45,8 +42,6 @@ public class RouteStepsActivity extends SherlockFragmentActivity {
private List<Boolean> pointsStartState; private List<Boolean> pointsStartState;
private PointItemAdapter adapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.setContentView(R.layout.route_steps_main); super.setContentView(R.layout.route_steps_main);
@ -88,14 +83,30 @@ public class RouteStepsActivity extends SherlockFragmentActivity {
} }
} }
adapter = new PointItemAdapter(this,R.layout.route_point_info, pointItemsList); PointItemAdapter adapter = new PointItemAdapter(this, R.layout.route_point_info, pointItemsList);
ListView listView = (ListView) findViewById(R.id.pointsListView); final ListView listView = (ListView) findViewById(R.id.pointsListView);
listView.setAdapter(adapter); listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
final PopupMenu menu = new PopupMenu(RouteStepsActivity.this, view);
menu.getMenuInflater().inflate(R.menu.route_step_menu, menu.getMenu());
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getTitle().equals("Mark as next")){
} else {
}
return true;
}
});
menu.show();
} }
}); });
} }
@ -108,13 +119,12 @@ public class RouteStepsActivity extends SherlockFragmentActivity {
Map<String, String> map = gpx.getExtensionsToRead(); Map<String, String> map = gpx.getExtensionsToRead();
if (map.containsKey(CURRENT_ROUTE_KEY)) { if (map.containsKey(CURRENT_ROUTE_KEY)) {
String routeName = map.get(CURRENT_ROUTE_KEY); String routeName = map.get(CURRENT_ROUTE_KEY);
int i = 0;
for (GPXUtilities.Route route : gpx.routes) { for (GPXUtilities.Route route : gpx.routes) {
if (route.name.equals(routeName)) { if (route.name.equals(routeName)) {
currentRoute = route; currentRoute = route;
return; return;
} }
i++;
} }
} }
currentRoute = gpx.routes.get(0); currentRoute = gpx.routes.get(0);