Reputation: 1614
I am creating an application that saves GPS coordinates; I have created a button which launches a new Activity to display, as a list all the save coordinates. The program crashes a soon as I hit the button, here is what I am doing.
class 1:
public void openLatLonData(View view)
{
Intent intent = new Intent(this, GpsDataList.class);
ArrayList<String> allLocalStrings = new ArrayList<String>();
for(int i =0; i< AllLocals.size();i++)
{
allLocalStrings.add(AllLocals.get(i).getLat());
allLocalStrings.add(AllLocals.get(i).getLon());
}
intent.putStringArrayListExtra("data", allLocalStrings);
startActivity(intent);
}
This method calls the new activity:
public class GpsDataList extends ListActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle bundleIn)
{
super.onCreate(bundleIn);
Intent intent = getIntent();
ArrayList<String> listData = new ArrayList<String>();
listData = intent.getStringArrayListExtra("data");
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, listData));
getListView().setTextFilterEnabled(true);
//finish();
}
}
the button contains the following XML:
<Button android:layout_height="wrap_content"
android:text="Show Collected Data"
android:id="@+id/view_lat_lon_data"
android:layout_width="wrap_content"
android:onClick="openLatLonData">
</Button>
And I have added a new .xml file named gpsdatalist.xml under the res/layout folder:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
Lastly the manifest contains this: .
I believe I have all the pieces in play- Hopefully someones see the mistake Thanks in advance guys!
Upvotes: 0
Views: 1200
Reputation: 10353
Did you define the activity in the AndroidManifest.xml file? Anyway, your best clue resides in the logcat of your exception. You will solve it in 2 seconds after cheking the logcat.
Upvotes: 1