I have an activity made up of two fragments. On the left is a sidebar, on the right is a MapView (See screenshot below).
On the left I have a spinner that will be populated with objects on the map. Right Now, I have it hardcoded with some values until I figure out this issue. When the Spinner is selected, a dialog appears, but it is empty. Any idea what is going on?
Here is my code for the left fragment (Its not very complex):
package android.splitdisplay;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
public class SideFragment extends Fragment {
String[] tracks = { "ObjectOne", "ObjectTwo",
"ObjectThree"
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getActivity().setContentView(R.layout.sidefragment);
final Spinner s = (Spinner) this.getActivity().findViewById(
R.id.track_spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this
.getActivity().getBaseContext(),
android.R.layout.simple_spinner_item, tracks);
s.setAdapter(adapter);
s.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
int item = s.getSelectedItemPosition();
Toast.makeText(SideFragment.this.getActivity().getBaseContext(),
"clicked "+item, Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
public void onListItemClick(ListView parent, View v, int position, long id) {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.sidefragment, container, true);
}
}
Here is the XML for the SideFragment:
<?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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Tracks"
android:textColor="#adff2f"
android:textSize="30sp" />
<Spinner
android:id="@+id/track_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="@string/track_prompt"
android:spinnerMode="dialog" >
</Spinner>
</LinearLayout>
Here is what I am seeing when I click on the spinner:
Here is all of the source code in a zip:
http://db.tt/KMGXhZWc