POI のリストの緯度、経度を含む php から xml コードを (XML DOM メソッドによって) 解析しました。別のクラスのピンを使用してすべてのポイントを表示したいと考えています。問題は、アプリを開いたときにリストビューが必要ないことです。マップを開いてすべてのマーカーを表示する必要があります。誰かがこれについて私を助けてくれますか? 前もって感謝します。
コード
import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class ParseXMLaroundme extends ListActivity{
String latitude;
public ParseXMLaroundme () {
// TODO Auto-generated constructor stub
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aroundme);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
String xml = ParseXMLMethods.getXML();
Document doc = ParseXMLMethods.XMLfromString(xml);
/*
int numResults = ParseXMLMethods.numResults(doc);
if((numResults <= 0)){
Toast.makeText(ParseXMLDemo.this, "There is no data in the xml file", Toast.LENGTH_LONG).show();
finish();
}
*/
NodeList children = doc.getElementsByTagName("ListingElement");
for (int i = 0; i < children.getLength(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element)children.item(i);
map.put("ItemID", ParseXMLMethods.getValue(e, "ItemID"));
map.put("ImageURL", ParseXMLMethods.getValue(e, "ImageURL"));
map.put("VideoURL", ParseXMLMethods.getValue(e, "VideoURL"));
map.put("AudioURL", ParseXMLMethods.getValue(e, "AudioURL"));
map.put("StartDate", ParseXMLMethods.getValue(e, "StartDate"));
map.put("EndDate", ParseXMLMethods.getValue(e, "EndDate"));
map.put("ItemName", ParseXMLMethods.getValue(e, "ItemName"));
map.put("Address", ParseXMLMethods.getValue(e, "Address"));
map.put("Suburb", ParseXMLMethods.getValue(e, "Suburb"));
map.put("Postcode", ParseXMLMethods.getValue(e, "Postcode"));
map.put("Longitude", ParseXMLMethods.getValue(e, "Longitude"));
map.put("Latitude", ParseXMLMethods.getValue(e, "Latitude"));
map.put("SubtypeName", ParseXMLMethods.getValue(e, "Subtypename"));
map.put("Cost", ParseXMLMethods.getValue(e, "Cost"));
map.put("Details", ParseXMLMethods.getValue(e, "Details"));
map.put("Website", ParseXMLMethods.getValue(e, "Website"));
map.put("MajorRegionName", ParseXMLMethods.getValue(e, "MajorRegionName"));
map.put("Phone", ParseXMLMethods.getValue(e, "Phone"));
map.put("Email", ParseXMLMethods.getValue(e, "Email"));
map.put("OpeningHours", ParseXMLMethods.getValue(e, "OpeningHours"));
String targetlatitude=map.get("latitude");
String targetlongitude=map.get("longitude");
Double targetlat = Double.valueOf(targetlatitude);
Double targetlng = Double.valueOf(targetlongitude);
mylist.add(map);
}
/*
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.me_layout,
new String[] { "Latitude", "Longitude", "VideoURL", "StartDate", "EndDate", "ItemName" },
new int[] { });
setListAdapter(adapter);
*/
final ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);
Toast.makeText(ParseXMLaroundme.this,o.get("NewsBody"), Toast.LENGTH_LONG).show();
}
});
}
}