hi i am trying to create 2 lists in one screen. i am using the google api places where i want the list to appear then when selected the result will appear, this what i have so far but the second list doesnt appear and i am not sure why
public class listSearch extends ListActivity implements
OnItemClickListener, OnItemSelectedListener, OnClickListener {
private PlaceList places;
private HttpRequestFactory hrf;
private String location;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
location = Config.LOCATION;
ListView lv1=(ListView)this.findViewById(android.R.id.list);
String[] placeSearch = getResources().getStringArray(R.array.typeList);
ArrayAdapter list1 = new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_1,placeSearch);
lv1.setAdapter(list1);
/* Use the LocationManager class to obtain GPS locations */
LocationManager mlocManager =
(LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
mlocListener);
}
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc)
{
location = "" + loc.getLatitude() + "," + loc.getLongitude();
/*
String Text = "My current location is: " +
"Latitud = " + loc.getLatitude() +
"Longitud = " + loc.getLongitude();
Toast.makeText(getApplicationContext(),
Text,
Toast.LENGTH_SHORT).show();
*/
}
@Override
public void onProviderDisabled(String provider)
{
Toast.makeText(getApplicationContext(),
"Gps Disabled",
Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled(String provider)
{
Toast.makeText(getApplicationContext(),
"Gps Enabled",
Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}/* End of Class MyLocationListener */
@Override
public void onClick(View v) {
}
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
String type = parent.getItemAtPosition(pos).toString().trim();
hrf = TouristHttpTransport.createRequestFactory();
Resources res = getResources();
try {
HttpRequest request = hrf.buildGetRequest(new GenericUrl(
res.getString(R.string.places_search_url)));
request.getUrl().put("key", res.getString(R.string.google_places_key));
request.getUrl().put("location", location);
request.getUrl().put("radius", Config.RADIUS);
request.getUrl().put("types", type);
request.getUrl().put("sensor", false);
Log.i(Config.MSGTAG, "Request: " + request.toString());
places = request.execute().parseAs(PlaceList.class);
Log.i(Config.MSGTAG, "Response: " + places.getStatus());
List<String> titles = new ArrayList<String>(places.getResults()
.size());
for (Place p : places.getResults()) {
titles.add(p.toString());
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.place_title, R.id.placeTitle, titles);
ListView l = (ListView) this.findViewById(R.id.placeList);
l.setAdapter(adapter);
l.setOnItemClickListener(this);
} catch (IOException e) {
Log.e(Config.MSGTAG, e.getMessage());
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Place p = places.getResults().get(position);
Intent i = new Intent(this, ViewPlaceDetails.class);
i.putExtra("place", p);
startActivity(i);
}
}
The XML file called main1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="215dp" >
</ListView>
<ListView
android:id="@+id/placeList"
android:layout_width="wrap_content"
android:layout_height="215dp"
android:layout_weight="0.80" >
</ListView>
</LinearLayout>
any help would be appreciated